How to determine where collision takes place.

GamersRejoiceGamersRejoice Member Posts: 817
edited November -1 in Working with GS (Mac)
I'm trying to figure out how to make my actor behave a certain way when he touches a wall, but I want the behavior to be different based on which side he actually collides with (top, bottom, left, right). How could I do this?

Comments

  • latygo60latygo60 Member Posts: 27
    Constraining actors to its top,botom,left & right sides, and fixing rotation.
  • GamersRejoiceGamersRejoice Member Posts: 817
    Well sure I could do that, I'm hoping someone has a method that is more lightweight than the constraining method.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    depending on what your doing exactly you could change 2 attributes to the x and y of the object you hit on collision and compare the players position x or y to that. So if your players position x is greater then objects position x you know its to the right when the collision takes places, and the same goes if its less then for the left side. and the same for y if its y position is greater then the object when the collision happens its above it and if its less then its below it.
  • RedlerTechRedlerTech Member Posts: 1,583
    Create an attribute called angleHit

    When overlaps or collides,

    change angleHit to vectorToAngle(self.position.x-otherActorX, self.position.Y-otherActorY)
    //This should give you an angle in which the collide happened.
    Put a rule inside this rule after the change attribute about what angle it hit etc
  • GamersRejoiceGamersRejoice Member Posts: 817
    JohnPapiomitis said:
    depending on what your doing exactly you could change 2 attributes to the x and y of the object you hit on collision and compare the players position x or y to that. So if your players position x is greater then objects position x you know its to the right when the collision takes places, and the same goes if its less then for the left side. and the same for y if its y position is greater then the object when the collision happens its above it and if its less then its below it.

    NextGen said:
    Create an attribute called angleHit

    When overlaps or collides,

    change angleHit to vectorToAngle(self.position.x-otherActorX, self.position.Y-otherActorY)
    //This should give you an angle in which the collide happened.
    Put a rule inside this rule after the change attribute about what angle it hit etc

    Great ideas! I'll have to play around with these. Thank you.
Sign In or Register to comment.