Jump to content

Three.js - Collision detection on imported models


pipd0un
 Share

Recommended Posts

I'm trying to make a turn based rpg scene with 3d models. I got glTF exports from blender and their animations from mixamo.

I've a constructor like; 

constructor() {

        this.clock = new THREE.Clock();
        this.scene = new THREE.Scene();
        this.loader = new THREE.GLTFLoader();

        this.mixer;
        this.mixerEn;

        this.fog = false;

        this.animations = ["Idle", "Kick", "Stun"];
        this.animationsEn = ["IdleSaf", "HitSaf"];

        this.actions = [];
        this.actionsEn = [];

        this.init();
        this.animate();
    }

then loaded models and their animations;

loadModels() {
        // main model
        this.loader.load('glb/Es.glb', (object) => {

            this.mixer = new THREE.AnimationMixer(object.scene);
            object.scene.position.set(-250,0,0);
            object.scene.rotation.y = Math.PI / 2;

            if (object.scene.isMesh) {
                object.scene.castShadow = true;
                object.scene.receiveShadow = false;
            }

            this.scene.add(object.scene);
            this.loadAnim();
        });

        //opponent
        this.loader.load('glb/Es.glb', (object) => {

            this.mixerEn = new THREE.AnimationMixer(object.scene);
            object.scene.position.set(250,0,0);
            object.scene.rotation.y = -Math.PI / 2;

            if (object.scene.isMesh) {
                object.scene.castShadow = true;
                object.scene.receiveShadow = false;
            }
            this.scene.add(object.scene);
            this.loadAnimEn();
        });
    }

the problem is main character's kick pass though opponents stomach, want to detect that so I can play a stun or fade animation for opponent. Most of collision methods for basic meshes like sphere and cube. I dont know what to do.

scene.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...