When setting followerEntity.isStopped, the AI’s rotation is being reset to (0,0,0). We have a unit that flies in the air and does not use A* pathfinding while airborne but starts using the A* asset once it lands.
Upon landing:
ai.enabled = true;
ai.isStopped = true;
After the landing animation is complete:
ai.isStopped = false;
Sometimes, every time isStopped is set, the AI’s rotation is set to (0,0,0).
How can this issue be resolved?
Additionally, even if we prevent rotation by setting ai.updateRotation = false during landing, when we set ai.isStopped = false and ai.updateRotation = true after the landing animation, the rotation is again reset to (0,0,0).
A few questions as I’m not seeing this behavior on my end:
When are you seeing the rotation set to zero? Is it only for a frame then snap back to the correct rotation? Or does it start at zero and rotate towards the correct rotation smoothly over many frames?
Yeah I’m able to replicate this too now, and I’m unable to find any way to start the component with a rotation already set. There may be a way but I’m missing it. I’ll see what @aron_granberg thinks about it.
This is one of things I tried though:
var follower = GetComponent<FollowerEntity>(); // Get the component
originalRot = transform.rotation; // Hold the rotation
follower.enabled = true; // Enable the currently disabled component (disabled in Awake)
follower.isStopped = true; // Let it move
follower.rotation = originalRot; // Now, give the follower entity the original rotation
follower.updateRotation = true; // Allow it to rotate (disabled in Inspector)
Perhaps the component should be turned on from the start, but have Position Sync and Rotation Sync, have no path, etc until you’re ready for it to have one? Not sure. I’ll ask
Initially, I set updateRotation = false to prevent rotation, but after the landing, when I change it back to updateRotation = true, the rotation resets to (0, 0, 0).
The reason I set updateRotation = false is that when updateRotation = true, even if I forcefully change the rotation in the scene, it stays locked at (0, 0, 0).
(I believe ai.rvoSettings.locked is unrelated to the issue, as there’s no difference when it’s removed.)
Yeah I tried a lot of things on my end as well. The code I provided was just to have a record of what I tried, not particularly a solution I tried a bunch of other things too, like moving things from Awake to Start, Coroutines, etc. I guess we’ll see haha