Rotate towards angle in specific direction

Get help using Construct 2

Post » Sat Nov 12, 2011 9:35 pm

Hi there,

Just wondering if there's a simple way to use the 'rotate towards angle" action, but restrict it to a specific direction, eg. clockwise.

Thanks in advance
B
9
S
4
G
5
Posts: 136
Reputation: 2,952

Post » Sat Nov 12, 2011 9:58 pm

If you input possitive value, it will rotate clockwise
- Sprite rotate 2 degrees toward 60 (will rotate the sprite clockwise by 2 degrees toward angle 60)
Negative, counter-clockwise
- Sprite rotate -2 degrees toward 60 (will rotate the sprite counter-clockwise by 2 degrees toward angle 60)
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Sat Nov 12, 2011 10:12 pm

Thanks for the reply.

This seems to cause problems for me. It's like it's choosing the direction based on the shortest distance.

I'm rotating towards 0

I've basically got it set up so if the object is moving left, and it jumps, it will rotate counter-clockwise. Then I'm using the "rotate towards angle" when it's falling to straighten it out. And likewise for when it's moving right.

On the odd occasion it rotates the opposite way when it's falling, though most of the time, it's going the correct way. This is just by setting the "rotate towards angle" degrees to 10.

Really I'm just trying to get rid of those odd times when it's wrong.

B
9
S
4
G
5
Posts: 136
Reputation: 2,952

Post » Sat Nov 12, 2011 10:15 pm

Can you upload the .capx or reproduce that part in a new one?
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Sat Nov 12, 2011 10:32 pm

http://dl.dropbox.com/u/12109568/Test.capx

Arrows to move, ctrl to jump (you can jump multiple times)

Thanks
B
9
S
4
G
5
Posts: 136
Reputation: 2,952

Post » Sat Nov 12, 2011 11:53 pm

I haven't seen the problem, but I tried this. Check it out if it's ok, should be always rotating correctly.

edit> I just changed it a bit. Now you can't change the direction of rotation until the sprite made one full rotation.
downloadNoga2011-11-13 00:00:16
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Sun Nov 13, 2011 12:08 am

Ah nice, thanks heaps Noga.

Much appreciated!
B
9
S
4
G
5
Posts: 136
Reputation: 2,952

Post » Thu Apr 11, 2013 8:48 pm

Thanks for this Noga. I was struggling to figure out how to set it so that it would rotate in the direction that the player is moving in - even though in my head I knew the logic. Much appreciated.
B
3
Posts: 1
Reputation: 427


Return to How do I....?

Who is online

Users browsing this forum: Megavolt, mnashwan and 20 guests