How do I rotate object by angle loop

Get help using Construct 2

Post » Fri May 20, 2016 2:36 pm

Hello,
I was trying to build something simple. Camera that moves within the defined angle range. Lets say, I have a camera and I want it to look through the area of 40 degrees, so it will move from 0 degrees to 40 degress wait 1 second and go back to 0 degress and then repeat this process endless times.

Here is what I've done, I've made a system repeat that every 3 seconds Sprite 1 will set its angle to 20 degrees wait 1 second and then set angle to 0 degrees.
The issues is that it's not rotating at all, it just jumps between the states from 20 to 0 degrees and I want the came to rotate slowely.

How can this be done?
B
11
S
3
Posts: 44
Reputation: 713

Post » Fri May 20, 2016 2:43 pm

Rotate toward angle
Rotate the object a number of degrees toward another angle. If the object is close to the target angle it will not overshoot (it will end up exactly at the target angle).
Try this instead of setting your sprite angle
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Fri May 20, 2016 3:35 pm

I assume this is what you've been suggesting:
Image

Only the first time is doing it the right way, after that it starts to twitch for 1/2 degrees every secound or so.
B
11
S
3
Posts: 44
Reputation: 713

Post » Fri May 20, 2016 4:47 pm

after sprite rotate 10 degrees toward 0 add an action set variable rotate = 0 :)

I could explain how using the wait 0.5 second is not the smartest way to handle this ... but seeing as your in a learning curve ... I would just go with the rotate = 0 and follow up with events and actions after that :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Fri May 20, 2016 5:15 pm

I've done something similar
Image
B
11
S
3
Posts: 44
Reputation: 713

Post » Fri May 20, 2016 8:01 pm

B
78
S
23
G
69
Posts: 1,353
Reputation: 43,985

Post » Fri May 20, 2016 9:50 pm

gamecorpstudio wrote:like this?

Thanks I'll look into this one too
B
11
S
3
Posts: 44
Reputation: 713

Post » Sat May 21, 2016 3:06 pm

StanBond wrote:
gamecorpstudio wrote:like this?

Thanks I'll look into this one too

I've looked into your file, thanks that was great. However, I've a question about it.

What if I make a square1, add drag and drop to your square2. Whenever I put square 2 overlapping square 1, square 2 should rotate by 15 degrees and then keep on with the rotation taking into account the 15 degree offset
B
11
S
3
Posts: 44
Reputation: 713


Return to How do I....?

Who is online

Users browsing this forum: Kin, mickclarke, newt, TRMG and 44 guests