I'm trying to make a ship rotate at a speed with some inertia. To if the direction to rotate to is flipped than it's not going to instantly turn to the angle at full speed, but rather sow down turning the other way then seed up, exactly like the angular velocity in physics (Which I cannot use for this project)
I can work it up with code but it would take 4-5 lines with some funkay computations.
Is there a simple math in Construct that can do this?
You could use a private variable to store rotation speed. Whenever you hold down the right or left keys you would either add or subtract a certain amount from this variable. Then you would apply the rotation speed to the object by setting it's angle to: Object.Angle + RotationSpeed * TimeDelta
Yeah, thanks I had that worked out sort of. But my controls are you turn an arrow that points the direction and the ship rotates to that arrow, and the problem of a rotation speed is that when it reaches the arrow the ship will over shoot it, then slow down, then over shoot the other side then slow down etc.
Is there some way to get if the ship needs to rotate clockwise and return (1) or counter-clockwise and return (-1)?
Oh, right, momentum. Hmm, now that'd be a little trickier. There is no simple way to do this that I can think of at the moment.
You'd have to create a 'momentum' variable that you add to whenever the ship thrusts toward desired angle and remove from when you thrust in the opposite direction. That 'momentum' variable would then affect the rotation speed.
Try something like: always set angle to anglediff*0.9
The bigger the angle difference, the faster it will turn (there are various ways to cap the speed), and it won't overshoot when it gets to the right angle.
Also, what I typed won't work exactly because it doesn't have timedelta. It should look like: always set angle to anglediff*(somenumber*timedelta) but I can't remember what somenumber's supposed to be for that. Try experimenting with what number should be there.