How to get an actor to detect anothers movements
Hi guys!
I am having trouble finding a way of getting an actor to know which direction another actor is coming from, (in this case a block which has just been selected needs to know where the last selected block was).
I am working with Tshirtbooth's template shown here:
http://gshelper.com/connected-boxes-in-gamesalad-video-demo-tutorial/
Unless there is a better way of doing it, I had the idea to get an additional actor to follow the selected block one step behind it. So any actor would always know where the selected block had just been - but there may be a better way.
Many thanks in advance,
Max
I am having trouble finding a way of getting an actor to know which direction another actor is coming from, (in this case a block which has just been selected needs to know where the last selected block was).
I am working with Tshirtbooth's template shown here:
http://gshelper.com/connected-boxes-in-gamesalad-video-demo-tutorial/
Unless there is a better way of doing it, I had the idea to get an additional actor to follow the selected block one step behind it. So any actor would always know where the selected block had just been - but there may be a better way.
Many thanks in advance,
Max
Best Answers
-
RThurman Posts: 2,881
Could you record the previously selected block's x,y coordinates?
Then you could check the previous coordinates against the currently selected block's coordinates:
if (previousX - currentX) > 0 then the previous actor is to the left
if (previousY - currentY) > 0 then the previous actor is above -
RThurman Posts: 2,881
The easiest way to record them would be to use two game level attributes. Make them type real. Name them 'previousX' and 'previousY'.
This method will work on diagonals as well. To check blocks on the diagnoal you would need to check both x and y positions. For example:
if ((previousX - currentX) > 0 _and_ (previousY - currentY) > 0) then the previous actor is above and to the left
Answers
Many thanks
Max
Max
I am just compiling all of the stuff RT has very kindly said, and will get back when I can confirm it works