Here is what I want:
- Spawn a bullet, set position, rotation and velocity
- Lock bullet to x-z plane and lock rotation to y-axis rotation
Here is what I do:
- Cloning a deactivated projectile from hierarchy, setting position / velocity / rotation and activating it
- Adding a script to lock the position and rotation
- The lock script reads the entity position, resets the y value and sets it on the entity again ans synchronizes the body’s position via calling syncEntityToBody()
Here is what is odd when NOT adding the position lock script:
- The bullet appears for a few frames at 0,0,0 before being shown at the actual position, moving the right direction with the right orientation
Here is what happens when adding the position lock script:
- When the entity position is read in the initialize call, it has the correct coordinate from spawning the entity
- When the first frames are evaluated, getting the position via getPosition gives me the 0,0,0 coordinate (contrary to the initialize call)
I have tried using teleport, ignoring the first few frames and changing the activation order. It doesn’t help. It seems that a freshly initialized rigidbody starts out an initializer position before being updated. It reminds me of what happens in Unity when doing things in the Update call when you’re supposed to use the FixedUpdate callback to be in sync with the physic stepping.
Any suggestions how to fix this? It’s also not nice that I can see the object at 0,0 when the thing spawns. I read that the fixed update calls have been removed in the past; how am I able now to do things synchronized with the physics stepping?