Jump to content


Photo

Smooth rotation


  • Please log in to reply
2 replies to this topic

#1 Luisiroth

Luisiroth

    GMC Member

  • New Member
  • 10 posts
  • Version:GM8

Posted 28 May 2012 - 05:04 PM

Hi there, I´m new to this forum and I want to learn a lot with all of you!

Here is my first question. I use an script like this to change the sprite of an object based on the direction it´s facing:

"if direction > 0-20 and direction < 0+20 {sprite_index=character0}"

Everything works fine, but it changes the direction suddenly. I´m working on a little "point and click" spaceship strategy game and I need the ships to change direction smoothly and at a certain speed. For example:

The ship is looking upwards (0 degrees) and I want to move it to the right (90º). I have a different sprite for every 10 degrees. How I can do an smooth animation for that change of direction at a fixed speed (faster for smaller ships and slower for bigger ships)???

Thanks a lot in advance, people!!!

Edited by Luisiroth, 28 May 2012 - 05:05 PM.

  • 0

#2 Jake Armstrong

Jake Armstrong

    GMC Member

  • GMC Member
  • 390 posts

Posted 28 May 2012 - 11:54 PM

Firstly, generally in Game Maker right is 0 degrees, up is 90, left is 180, down is 270.

In your current code, use a variable like facedir instead of direction, so you can have it point and move different directions.

Then, when the direction you are moving (direction) is different from the direction you are facing (facedir), you want facedir to rotate toward direction. There are topics on this, including one I just posted in. See http://gmc.yoyogames...1
  • 0

#3 Luisiroth

Luisiroth

    GMC Member

  • New Member
  • 10 posts
  • Version:GM8

Posted 29 May 2012 - 03:46 PM

You are right about the degrees, my error. And thanks for the advice and the link, I´ll give them a try!

Edited by Luisiroth, 29 May 2012 - 03:47 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users