my enemy isnt following the player.
here is my game
https://playcanvas.com/project/1180382/overview/pest-patrol
my enemy isnt following the player.
here is my game
https://playcanvas.com/project/1180382/overview/pest-patrol
Character Y pos is 1.895.
enemy Y pos is 0.
So
this.entity.lookAt(this.thePlayer.getPosition());
this.force.copy(this.entity.forward).scale(3);
this.entity.rigidbody.applyForce(this.force);
gives a force with Y.
Change to
var lookPos = new pc.Vec3(this.thePlayer.getPosition().x, this.entity.getPosition().y, this.thePlayer.getPosition().z);
this.entity.lookAt(lookPos);
this.force.copy(this.entity.forward).scale(3);
this.entity.rigidbody.applyForce(this.force);
might help
Also, dont forget to change the lookat script for the Y reason. Maybe just delete it.
it says Vec3 isnt defined
still not following my player
Sorry, should be
still not working
this.thePlayer = this.app.root.findByName("Patrol")
;
should be
this.thePlayer = this.app.root.findByName("Character")
;
I think
the enemy kinda follows the player now but its like rotating and walking on different paths before getting close to the player and its not also totally in front of the player when it follows it
Try set this.entity.rigidbody.linearVelocity
directly. But not add a force.
Like this.entity.rigidbody.linearVelocity = this.entity.forward;
its not working , can I give you editor access?
Yes. Sure