[SOLVED] How to wait for rotation to finish?

Heyo, I’m trying to rotate the player toward a location they can input. Here’s the code:

This code works perfectly when I make the rotation instant (by making the rotation speed 0 deg/second). The problem is that when it isn’t instant, the rotation (I think) is interrupted midway by the next action. I couldn’t find a condition that waits for the rotation to be finished, which I think I’d need in this situation.

Am I missing something or is there a way to approach this differently? Thanks!

The issue is when rotating an object based on speed, it will take a different amount of time to reach its target angle. You could increase the wait time but that would add a pause for shorter rotations. I guess you could calculate the wait based on the amount it needs to turn.

A more consistent and reliable way would be with a chain of tweens. For a consistent rotation, you would still need to set the time based on change in degrees / speed

Start angle tween

Tween angle finished
Delete tween and start position tween

Position Tween done
Delete tween and do whatever.

Increasing the wait time does not work as you said it would :cry: I gave the spaceship ample time to complete its rotation.

I made the player spaceship move north, which means it should rotate -90 degrees. Through the debugger, I found out that the player’s spaceship barely changed angle, which tells me something is immediately stopping/overwriting the action.

If I were to use angle tweens, I don’t know how to calculate the angle toward the position the player chose. The game is turn-based, if that means anything.

Thanks for the reply!

Sorry, I wasn’t thinking. The rotate only moves a little because it needs to be triggered on every frame and your event has a trigger once.

This targets the cursor position. You can use whatever. It turns at 100 degrees per second and moves at 100 pixels per second. I believe. You can change the 100s.

I’m not 100% on this. It might be easier to use the pathfinder. IDK. It depends on your needs.

Thank you! Simply making another event without the trigger once condition made it work perfectly! Final code for reference:

I was fiddling around with the pathfinder, it was just too complicated for my needs. Thank you for the suggestion anyway.

1 Like