Actor Location Tracking

spazspaz Member Posts: 6
edited November -1 in Working with GS (Mac)
I want to do something (start a timer & animate) an actor when the actor is dragged to a location that is within a certain area. I can handle the timer and animation, but I need help with the location tracking. The location is a rectangular area that is fixed (does not change during the game). I came across this article - http://gamesalad.com/wiki/how_tos:gsc_track_if_actor_is_over_another, which I may be able to adapt, but there may be a better way so I wanted to check with you guys first. Thanks in advance for pointing me in the right direction.

Comments

  • HachikoHachiko Member Posts: 330
    A rectangle is made of four sides.
    Let's take a rectangle that has the <- side at 0, the -> 100, the up side at 100 and the down side at 0.
    Now, if player.x is > of 0, and < of 100, then it is between the rectangle vertical sides.
    if player.y is > of 0 and < of 100, then it is between the rectangle vertical sides.

    So, if player.x is > of 0, and < of 100
    if player.y is > of 0, and < of 100
    then player is inside the rectangle.
    If you want to make that it doesn't just check the x and y position (the center of the player object) but if the whole player object is inside the rectangle, make it a square.

    if player.x is > of 0 + player.width, and < of 100 - player.width
    if player.y is > of 0 + player.height, and < of 100 - player.height
    then player is inside the rectangle.

    Hope this helps :)
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Being a rectangle you may have to use an invisible actor to define your area. There are other ways using attributes and I believe magnitude to track if an actor is within range of a certain position
  • spazspaz Member Posts: 6
    Hachiko said:

    if player.x is > of 0 + player.width, and < of 100 - player.width
    if player.y is > of 0 + player.height, and < of 100 - player.height
    then player is inside the rectangle.

    Hope this helps :)

    That makes sense, I've give a try. Thanks!

Sign In or Register to comment.