Angles

GnomerGnomer Member Posts: 292
edited February 2012 in Working with GS (Mac)
Okay so i was wondering how you work out what angle one actor hits another at. Because i want to have it so that when one actor hits another the other bounces off in the angle they hit. At the moment the actors just hit one another and both stop. I have restitution on.

Thanks :)

Comments

  • CloudsClouds Member Posts: 1,599
    edited February 2012
    "how you work out what angle one actor hits another at "

    Just check what the rotation is when the actors hit each other, here's a very quick example . . .

    http://www.mediafire.com/?aiyb3ec5u6z22bu
  • GnomerGnomer Member Posts: 292
    Thanks @tynan :)
  • GnomerGnomer Member Posts: 292
    edited February 2012
    Does anyone know how I can use this so that when one actor (controlled by the mouse) hits another actor the other actor moves in the direction it was hit?

    If it helps the actors are both on circular collision.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Try this.

    Make an angle attribute called collisionAngle

    Make 2 real attribute, and call them grabbedactorX and grabbedActorY

    Make a boolean self attribute in the actor you want to move when hit called moveOn



    In the actor you move with the mouse,
    constrain attribute grabbedActorX to self.position.x
    and constrain grabbedActorY to self.position.y

    If you havent already, to make it move with the mouse when touched have this rule:

    When touch is pressed
    -constrain self position.x to mouse.position.x
    -constrain self.position.y to mouse.position.y



    Now put these rules in the actor you want to move when hit:

    A rule when actor overlaps or collides with( actor that moves with the mouse)
    -change attribute collisionAngle to vectorToAngle(self.position.x-grabbedActorX,self.position.y-grabbedActorY)
    -change attribute moveOn to true

    the one more rule when attribute moveOn is true
    -the have change velocity behavior, have it set relative to scene, have the speed whatever you want, and for the direction set it to the collisionAngle attribute
Sign In or Register to comment.