Forum Discussion
sh0v0r
13 years agoProtege
FixedUpdate & Rigibody Interpolation
While integrating OVR into my game Lunar Flight I encountered several problems with using FixedUpdate and Rigibody interpolation. I thought I might share them in the hope that someone might suggest some solutions or at least others may be aware of what to look out for if they are doing a cockpit based game.
Stretched Particles
My game has a cockpit and I want to use world space stretched particles to help with the sensation of movement. What I discovered is that if you don't use Rigid body Interpolation you will see issues with the particles not having any length for multi frames that are greater than the Fixed Update rate. E.g. Your Fixed Update is 30 FPS but your rendered frame rate is 45 FPS. For each of the frames that are greater the particles will have no stretching because the physics has not updated their position. They appear to blink in and out of existence. Enabling interpolation fixes this issue but it introduces other problems.
Lens Flares
Lens flares rely on ray casting to the camera and test against colliders. If you are using interpolation then as the velocity increases the cameras position will be out of sync with the colliders and you will start to see the flare appearing through the body of your cockpit when it should not. I don't know if this is just a bug in Unity but if you have the collider selected and put the origin on 'centre' not 'pivot' you can actually see the location become offset as the velocity increases. It would seem that a Lens Flare shader that relies on depth buffer information would not be effected by this.
Cockpit Interaction
I have created a context sensitive interaction that casts rays into the cockpit from the centre of the eyes. Again if you use interpolation this will not be accurate as velocity increases.
So I have decided to fall back on using no interpolation, I considered setting the Fixed Rate really high to something like 120 FPS but this not an ideal option and people with really powerful hardware will still encounter this problem. I am going to try to come up with my own stretched particle system that manages its own particle objects and stretches them based on the Rigibody velocity.
Stretched Particles
My game has a cockpit and I want to use world space stretched particles to help with the sensation of movement. What I discovered is that if you don't use Rigid body Interpolation you will see issues with the particles not having any length for multi frames that are greater than the Fixed Update rate. E.g. Your Fixed Update is 30 FPS but your rendered frame rate is 45 FPS. For each of the frames that are greater the particles will have no stretching because the physics has not updated their position. They appear to blink in and out of existence. Enabling interpolation fixes this issue but it introduces other problems.
Lens Flares
Lens flares rely on ray casting to the camera and test against colliders. If you are using interpolation then as the velocity increases the cameras position will be out of sync with the colliders and you will start to see the flare appearing through the body of your cockpit when it should not. I don't know if this is just a bug in Unity but if you have the collider selected and put the origin on 'centre' not 'pivot' you can actually see the location become offset as the velocity increases. It would seem that a Lens Flare shader that relies on depth buffer information would not be effected by this.
Cockpit Interaction
I have created a context sensitive interaction that casts rays into the cockpit from the centre of the eyes. Again if you use interpolation this will not be accurate as velocity increases.
So I have decided to fall back on using no interpolation, I considered setting the Fixed Rate really high to something like 120 FPS but this not an ideal option and people with really powerful hardware will still encounter this problem. I am going to try to come up with my own stretched particle system that manages its own particle objects and stretches them based on the Rigibody velocity.
1 Reply
Replies have been turned off for this discussion
- sh0v0rProtegeA sort of solution for the stretched particles is to set your FixedRate to 60 FPS '0.016' and then with VSync on it works ok, assuming you can render a rock solid 60 FPS, there is the odd discrepancy but its acceptable.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 13 years ago