Detecting which side on a square actor a collision has occured?

GuardianGuardian Member Posts: 54
edited January 2012 in Working with GS (Mac)
Hey guys,

I have a square actor and want to be able to detect which side has been collided with by another actor. i.e. top, bottom, left and right.

I have a solution in mind. Create four new actors and place them on each edge of the square, then setup collision rules for each. However this doesn't feel like the most efficient method.

Thoughts?

Kind regards,
Guardian

Comments

  • PrimePrime Member Posts: 8
    Its funny, I was thinking of this yesterday.

    I was thinking of making a set of rules that would determine the direction movement of the actor that would collide into a cube.. by making a set of rules that reads out direction...then you can have different outcome on if you hit the square from different direction...that is assuming that the cube top left and right would always be oriented the same way(not rotate)

    I don't know if this would be the most efficient method. But it would be a different way than making more actors.
  • POMPOM Member Posts: 2,599
    My suggestion is :
    Upon collision , calculate the angle between the 2 actors (with vector to angle)
    Then you can use that value to detect the direction ..
    45-135 is up
    136-225 is left
    226-315 is down
    the rest (-45 to 45) is right

    Roy.
  • GuardianGuardian Member Posts: 54
    @Prime, amusingly enough I have actually already done this in form to detect the direction of a flying actor and rotate it accordingly. So I could do it this way. :)
  • GuardianGuardian Member Posts: 54
    @P-O-M, That is a very clever suggestion. Thank you.
  • PrimePrime Member Posts: 8
    @P-O-M, sounds like a cool way ... I don't know how to do the vector to angle. Is there a tutorial somewhere?
Sign In or Register to comment.