How to save a rotation to position?

akichan22akichan22 Member Posts: 9
edited March 2012 in Working with GS (Mac)
i want to change an actor image depend on the position where he is going,
im using 2 different actor, one for record in a game.attribute the self.rotation to position X,Y.
I would like to use only an actor.
sorry for my bad english. thank you for help

Best Answer

Answers

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited March 2012
    You don't need to record anything. Just make a rule, in your actor, that says when self.rotation is angle you want image to change. Change image to.
  • akichan22akichan22 Member Posts: 9
    but i cant use the self rotation because if the actor change his rotation, the image too rotate.
    mine is a monster that go to the hero, so i cant rotate it
  • MotherHooseMotherHoose Member Posts: 2,456
    how is your actor moving?
    is it just a rotation position?

    remember in coding it usually When then What
    so drag in a Note behavior
    type in it:
    When: self X = ? ; Y = ?
    What: change self image
    now you see you have to create a rule:

    Rule: when (All)
    Attribute: self.Position.X ≥ (moving right; or ≤ if moving left) the X you want for change
    Attribute: self.Position.Y ≥ (moving up; or ≤ if moving down) the Y you want for change
    --changeAttribute: self.Image To: the image you want

    image MH
  • akichan22akichan22 Member Posts: 9
    The actor is moving to position HeroX,HeroY
    I used like said FryingBaconStudios the rotation to position then the change image relative at the self position, i can modify the images but still don't know if possible to save the rotation in an attribute. ( i dont understand very well the attribute function, just few of those)
  • akichan22akichan22 Member Posts: 9
    edited March 2012
    ok i don't understand very well what vectortoangle do, but i check it
  • MotherHooseMotherHoose Member Posts: 2,456
    to monitor the rotation …
    drag a Display Text behavior into the rotatingActor
    Text: Expression: self.Rotation … or floor(self.Rotation) for no decimals

    on rotatingActor:
    (lower the rotationSpeed so you see the Rotation place for your imageChange )

    Rule: when
    Attribute: self.Rotation ≤ number for change
    --changeAttribute: self.image To: whatever

    simple demo of this: http://www.mediafire.com/?444f728uofg1we1

    image MH
  • akichan22akichan22 Member Posts: 9
    I used the VectorToAngle and it work perfectly, just saw the correct formula
    vectorToAngle(x-x',y-y')
    first then open this discussion i used it
    vectorToAngle(x,y) whit Hero X,Y and obviously it doesn't work..

    so thank you all
  • MotherHooseMotherHoose Member Posts: 2,456
    a vector is a direction to/from a point … a line that intersects to points

    in Rotation: Vector to Angle is the same as Rotate to Position

    and moveTo can also get you the end points of that vector

    little demo: http://www.mediafire.com/?rdoj0dvbzbz9bs3

    image MH
Sign In or Register to comment.