How to get an actor to detect anothers movements

JagonAppsJagonApps Member Posts: 241
edited September 2012 in Working with GS (Mac)
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

Best Answers

  • RThurmanRThurman Posts: 2,881
    Accepted Answer
    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
  • RThurmanRThurman Posts: 2,881
    Accepted Answer
    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

  • JagonAppsJagonApps Member Posts: 241
    Thanks for the reply RT, but what is the best way to record them? And also will this way work with a block moving in ALL directions? Including diagonal?

    Many thanks

    Max
  • JagonAppsJagonApps Member Posts: 241
    Thanks RT I will look into it tomorrow and get back.

    Max
  • JagonAppsJagonApps Member Posts: 241
    Hi there I have been trying to sort it out but I am having a mind blank and can't think how to record the previous block's co-ordinates, any help?
  • JagonAppsJagonApps Member Posts: 241
    Scratch that I have worked it out, if anyone wants to know how just let me know...basically just using attributes

    I am just compiling all of the stuff RT has very kindly said, and will get back when I can confirm it works
  • JagonAppsJagonApps Member Posts: 241
    Hi There! Eventually I have worked out a solution to the problem using a numbering system to detect what number the last block was, thank you very much RT Hurman
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Glad its working for you!
Sign In or Register to comment.