Hello, I want to make my entity move in the ‘direction’ of the mouse position,
Currently I am doing this in the OnMouseMove method:
var from = this.entity.getPosition(); this.pos = this.cameraEntity.camera.screenToWorld(event.x, event.y,10); var direction = new pc.Vec3(); direction.sub2(this.pos,from); direction.normalize(); var move = direction.clone(); move.scale(1000); move.y = 0; this.entity.rigidbody.applyForce(move);
I only want to apply force in the x and z axis. Please suggest me what I am doing wrong in the code above.