Launching an object in gamesalad

mikbiomikbio Member Posts: 54
edited November -1 in Working with GS (Mac)
Hello everyone,
I was messing around with the launch rule i saw on youtube on a tutorial i mean the one where you have to create 2 real atributes for the actor Touch X and Touch Y.
When i use this rule, the actors move great, but it rotates randomly as i move it in different directions. I was wondering if there's a way to make the actor rotate in the sense of the movement.

So if my actor is a boy, i would like that when i move it to the left he rotates with the head to the left and when i move it to the right he will rotate with his head to the right.

Any clues?

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    vectorToAngle(self.linear.motion.X,self.linear.motion.Y)

    Then You may need to adjust the image itself and also add in a rule to flip the image.
  • mikbiomikbio Member Posts: 54
    i've already used Constrain atribute self.rotation vectorToAngle(self.linear.motion.X,self.linear.motion.Y) in my rule but when i move the actor to the right it flips upside down and when i move it to the left it goes normal.
  • mikbiomikbio Member Posts: 54
    Maybe i haven't explained myself well.
    I would like that the actor upper side rotates in the direction of the movement. So if drag my actor to the north i have a rotation angle of 90° if i drag my actor to the south i have the upper side of my actor facing down with an angle of 270°, if i move the actor to the left i have the image with the upper side facing the left side with an angle of 180° and so on.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Are you wanting it to change rotation while it is constrained to the mouse x and y?

    If so, that is a totally different story. To do that you need to create some self attributes: self.X1, self.Y1, self.X2, and self.Y2

    Then you need to do this:

    Timer Every 0 seconds
    -----change attribute X2 to X1
    -----change attribute Y2 to Y1
    -----change attribute X1 to self.positionX
    -----change attribute Y1 to self.positionY

    constrain self.rotation to vectorToAngle( self.X1r - self.X2r , self.Y1r - self.Y2r )
    (this constrain is NOT in the timer)

    Just so you know, this will not be a perfectly smooth constrain. The better the device, the better it will look.
Sign In or Register to comment.