Arrow Pointer Implementation

Hi all,

I am looking to implement an arrow pointer in my game. This is basically to point the user to the direction of another entity. How can I achieve this?

You should take a look at the lookAt function. :grinning:
https://developer.playcanvas.com/en/api/pc.Entity.html#lookAt

You can see it implemented in the Information Hotspots sample project where that function is used to keep the hotspots pointing at the camera.

1 Like

:sweat_smile:
Thanks @wturber. Would you like to help out with game that we are developing? I would greatly appreciate it.

I don’t have the time or the skills. But thanks for the offer.

You’re welcome. Perhaps you could help us with our later games, when we both become better at this…

Perhaps. I just don’t think I’m on a gaming track right now. But I expect to be on this forum for a while, so you can always check in with me later.

Sure. Thanks a lot @wturber

@wturber, this is what happens when I use the lookAt function. Is there a way to get it pointing at me?

change the rotation as well:
https://developer.playcanvas.com/en/tutorials/billboards/
use something like this to get the lookAt the camera:
Also you would still have to change the local rotation (or EulerAngles) to get it to face with the laser end pointing at the player

1 Like

Can’t get it to work, can you fix it?

Point at points the negative Z axis of the object toward the target. Assuming you have set the target to “you” correctly and the script otherwise functioning right, I’d assume that you don’t have the gun barrel modeled so it is pointing on the negative Z axis. If my assumption is correct, you can fix it one of two ways.

  1. Re-orient the model so that the gun barrel is pointing in the negative Z direction and re-import.
  2. Create a new entity with no model or primitive - essentially creating a Null object. Assign your pointing script to that entity instead of to your gun. Parent your gun to that entity. Then rotate your gun horizontally to compensate for the fact that it is not modeled with the gun barrel pointing in the negative Z direction.
3 Likes

I’ll try that, thanks a lot @wturber