# Smooth rotation

4 replies to this topic

### #1 hhAnt

hhAnt

GMC Member

• GMC Member
• 3 posts
• Version:GM8

Posted 15 December 2012 - 11:54 AM

Hey,

Is there a way to rotate a simple figure smoothly?, e.g. a square, to spin it 45º when pressing a key I use

```image_angle = direction;
direction = 45;```

this make it in a abrupt way, how can I change the velocity of this motion? e.g. slow down

Pd. I´ve seen a similar topic in "Advanced GML discussion" section but is very complicated for me, I ask for a more straightforward answer if is possible
• 0

### #2 shinyjiggly

shinyjiggly

a lame wanderer

• GMC Member
• 129 posts
• Version:GM:Studio

Posted 15 December 2012 - 12:12 PM

Find a way to change the rate of the rotating smoothly over time until the the image has arrived at the correct rotation. The closer it is to the specified rotation, the slower it will go. Don't forget about the initial buffer, but try to have the amount of buffer dynamic as to not make it get in the way of other parts of the rate change.

Remember: it's not going to go 1 degree per step or whatever all the time, but depending on how close it is top its stopping point, it should adjust the rate until it evens out again. That being said, you'll probably need a variable for the interval, for the max rate, the direction goal, and maybe a couple others. Try to visualize it on a line graph. Would it be straight, or would it it be curved? Hopefully this has given you some hints on how to tackle this.
• 0

### #3 hhAnt

hhAnt

GMC Member

• GMC Member
• 3 posts
• Version:GM8

Posted 15 December 2012 - 05:53 PM

I´ll try to focus this way, I think it is using the elapsed time of the clock system, right?

greetings.
• 0

### #4 Nocturne

Nocturne

Nocturne Games

• 25708 posts
• Version:GM:Studio

Posted 15 December 2012 - 05:57 PM

• 0

### #5 hhAnt

hhAnt

GMC Member

• GMC Member
• 3 posts
• Version:GM8

Posted 15 December 2012 - 06:20 PM

thanks a lot, Nocturne.

Edited by hhAnt, 15 December 2012 - 06:21 PM.

• 0