Dumb angle/sine problem.

Get help using Construct 2

Post » Sat Jun 06, 2015 9:33 pm

I'm working on a snake that uses both the moveto and the sine behaviors. I want to tell the snake's head which angle to face based on the "moving angle" of the moveto behavior, which will be limited to 0,90,180,270.

Problem is, the moveto's "moving angle" expression is just the angle between the object's current and previous position, and the sine behavior screws it up. Instead of, say, 180, I get values between 160 and 170. I tried to make the snake face an angle if the moving angle was between these values, but that didn't work for some reason. I'm assuming this is because the variation of the sine is so great that my conditions overlap...or something.

So I'm wondering if there's some math I can use to remove the sine offset from the moveto's "moving angle" entirely. I think I need to calculate the difference of the angle w/ sine and the desired angle, then subtract it, but I dunno how to get the desired angle in the first place. Agh.

EDIT: Kinda solved this by rounding a separate move angle var to the nearest max deviation of the sine, then comparing that variable instead. So if the moveto's moving angle is within, say, 15 of 180, my var will be 180 and the snake will face it properly. Would still be nice to have the proper expression if anyone's got some free time though :P
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Sat Jun 06, 2015 10:53 pm

You answered it yourself, the simplest method is to use a dummy.
Image ImageImage
B
168
S
50
G
163
Posts: 8,224
Reputation: 105,067


Return to How do I....?

Who is online

Users browsing this forum: jkmalau and 14 guests