How to have an entity track

I need help on getting it so that an entity keeps track of the players direction when it is spawned, then rotating to match that, but not moving after that, so i can implement bullet holes.

Hi @Gavin_Durbin,

If you are trying to implement bullet holes then maybe a better idea is to work with the raycast result normal. That contains the orientation of the surface the bullet hit.

You can use it to align an entity to that vector to have your decal planes orientated across that surface.

Here is some example code on how to get that normal:

var hit = this.app.systems.rigidbody.raycastFirst(fromPos, toPos);

if(hit){
   console.log(hit.normal);
}
1 Like

Well, do you think that would still work with a projectile script?

Sure, you can still get the normal from collision results:

https://developer.playcanvas.com/en/api/pc.ContactPoint.html

Ok, thank you, this should be helpfull