Detecting Actors Positions Without Overlapping

Hey GS Community,
I'm making a game where I need to detect which actors are up, down, left, and right of the main actor (not diagonal). The actors are not touching each other though. Is there any way I could detect the positioning through maybe a table or attributes?

Thanks,
Micma

P.S. I have released my first app to the App Store. It has been 4 days with no update, but from what I read, it usually takes around 6 :)

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    If (self.position.x - otherActor.position.x) is greater than 0 
       then 
          otherActor is left 
       otherwise 
          otherActor is right
    
    If (self.position.y - otherActor.position.y) is greater than 0
       then 
          otherActor is below 
       otherwise 
          otherActor is above
    
  • micmamicma Member Posts: 66

    @RThurman said:
    If (self.position.x - otherActor.position.x) is greater than 0
    then
    otherActor is left
    otherwise
    otherActor is right

    If (self.position.y - otherActor.position.y) is greater than 0
    then
    otherActor is below
    otherwise
    otherActor is above

    Thank you so much! There are more than one actors that will be above/below or left/right, but the actors are 50x50. So I can figure out from here how to detect if only one actor is above/below or left/right. Sorry if that didn't make any sense.

Sign In or Register to comment.