# Sprites rotate instantly

Get help using Construct 2

### » Tue May 21, 2013 12:56 am

Hi, I have a problem where when I tell something to rotate toward angle instead of rotating it will just snap to the angle instantly. What am i doing wrong? thanks for any help people.
B
4
Posts: 17
Reputation: 234

### » Tue May 21, 2013 1:11 am

How are you using the action? On keypress, touch, etc.

The degree is how much it moves each time that Event is triggered. For example if:
One KeyDown Z
------->rotate 1 degree towards 270

This means, while I hold down the Z key the object will rotate 1 degree per tick towards 270.

B
101
S
32
G
12
Posts: 1,549
Reputation: 22,103

### » Tue May 21, 2013 1:20 am

I have it like this:

Condition: Sprite -> Land=2
Action: Sprite -> Rotate Clockwise: Anglediff(270, Fighter.Angle).

Also I tried:

Condition: Sprite -> Land=2
Action: Sprite -> Rotate Toward angle: Anglediff(270, Fighter.Angle) degrees toward (270)

Condition: Sprite -> Land=2
Action: Sprite -> Rotate toward angle: (1) degree toward (270)

KickAHobo2013-05-21 01:24:05
B
4
Posts: 17
Reputation: 234

### » Tue May 21, 2013 4:26 am

Hmm, that bottom one should work. Do you have a sample capx?
B
101
S
32
G
12
Posts: 1,549
Reputation: 22,103

### » Thu Jun 06, 2013 3:08 pm

I'm having a similar problem. I've tried tackling it several ways and seem kind of stuck.

Ideally, I want a limited-rotating turret to slowly move towards either 20-degrees left or right as long as either left or right arrow are held down.

My first attempt:
Turret.Angle = 270
On Left Arrow is down, Rotate Turret 5 degrees toward 250
On Right Arrow is down, Rotate Turret 5 degrees toward 290

In practice, what happens is as long as I hold left, the turret snaps to 265 (270-5) and stays there... so basically it's only updating that condition one tick when Left is pressed, rather than constantly while it's held down.

... I tried tackling it this way:

Turret.Vector = 0
Turret Angle = 270+Vector
On Left Arrow down, set Vector = -20
On Right Arrow down, set Vector = 20
Every Tick, rotate Turret 10 degrees toward Turret Angle (270+Vector)

Still no dice, it's rotating 10 degrees either direction only, so it's still updating only once. I just started using Construct 2 this week, so maybe there's something I'm missing about how to get this to update every tick?
B
3
Posts: 2
Reputation: 179

### » Thu Jun 06, 2013 3:17 pm

Wait. I found my problem.

Earlier on in the sheet when I spawned the turret item, I think I set its angle to 270 effectively locking it in place. Will check.

*edit* Yes, this was my problem. Changed the spawning logic to work once, instead of every tick fixed this.Kylo Cierra2013-06-06 15:21:34
B
3
Posts: 2
Reputation: 179

### » Thu Jun 06, 2013 8:13 pm

[QUOTE=KickAHobo] Hi, I have a problem where when I tell something to rotate toward angle instead of rotating it will just snap to the angle instantly. What am i doing wrong? thanks for any help people.[/QUOTE]

Did you multiply the angle in the degrees field with dt(deltatime)?
This should make a smooth rotation measured in degrees per second.
It looks something like so:

Sprite->Rotate 180*dt degrees toward OtherSprite.Angle

HF

B
19
S
2
G
1
Posts: 24
Reputation: 1,475