Hi all,
I am currently trying to make a sample spiderman model follow a non-descript keyboard controlled model:
GM-global test_4 | Editor (playcanvas.com)
I move spidey using a function moveAnimate (in pointAndClick script) and getting the current position (this.entity.getPosition()) of the player in the PlayerMovement script. Is there a way to keep spidey tracking the player?
Thanks, everyone.
Hi @spike_bump,
I am not sure I fully understand what you are trying to do. If you are looking for how to have an entity move towards a point this example may be of help:
https://developer.playcanvas.com/en/tutorials/point-and-click-movement/
1 Like
Hi Leonidas,
Thanks. I’ve been playing with the point and click movement for a few days now. I tried getting the player’s position via getposition in the update section of the PlayerMovement script and passing these to the moveAnimate function ing the point-and-click.js(heavily modified script to move spidey without using a mouse click) in an effort to make him follow.
Unfortunately, it only happens at the start, and the details from getPosition no longer replace the initial values in the function. Here is a screenshot of my console to see the discrepancy in the values:
The ones boxed in red are the initial values when the script starts. The one boxed in green are the values getPosition retrieves from the PlayerMovement script. The point-and-click section there also shows that the moveAnimate function passes the values, but it doesn’t go all the way to change the values of x,y,z in the other functions(movePlayerTo, update, etc.) of moveAnimate.
Is there a way to make these values reconcile so spidey will track the player’s location through getPosition?
should I include an event to make the code run again with the new params?
EDIT: tried using a keydown event(KEY_1), values remain unchanged.