•• Actor facing its direction? howz!? ••

OlsenOlsen Member Posts: 30
edited November -1 in Working with GS (Mac)
I have a scene with an actor that moves around colliding with other actors making it move to other directions, and having an actor face to the left and moving to the right just seems wrong and a bit retarded..

So.. Can anyone help me to make the actor change its self.rotation to the direction he is moving towards? (I dont only mean up, left, down and right. I need all directions)

I have thought of this so far:

Constrain Attribute:
Self.rotation to:
vectorToAngle( self.Position.X - 140 , self.Position.Y - 240)

It doesn't work.. Does anyone know if thats completely wrong or just needs some adjustments?

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
  • OlsenOlsen Member Posts: 30
    tshirtbooth said:
    what are you using to move the actor? touch? buttons?

    Nothing, it has a change velocity behavior when it spawns.

    direction random(1,360)
  • OlsenOlsen Member Posts: 30
    tshirtbooth said:
    ok try this

    make a self attribute self.direction (angle)

    on the actor tell it to change self.direction to random(1,360)

    then tell your movement to do in the direction of self.direction
    and then
    change attribute self.rotation to self.direction.

    I have tried that now and the actor's rotation was fine at the start but after it collided with something and changed direction, the rotation was still the same as it started.

    This problem happens because the "self.direction" angle attribute I made on the actor is equal to the direction it has when it spawns and doesn't change.

    Now I can only think of the solution to the problem is to use the function "vectorToAngle" but I am not quite sure how to use it..

    Does anyone know how to fix this?
  • OlsenOlsen Member Posts: 30
    please help!
  • OlsenOlsen Member Posts: 30
    Sweet! It works perfectly!

    As always tshirtbooth solves the problem, thanks! :)
  • mzxmzx Member Posts: 151
    Thanks tshirtbooth, i had almost the same problem and this fixes it! :D
Sign In or Register to comment.