- Home /
The question is answered, right answer was accepted
AddExplosionForce blast direction issue in v2017.3
In the v5.5 game, I translate an object just before applying explosion force and the object moves in the expected direction (awesome). But in v2017.3, in the same scenario, the object moves in the direction based on the original position and not the translated position. I created a new test scene in v2017 for testing and I can confirm this issue.
Steps to reproduce the issue: 1) Create 3 objects (projectile, trigger, and avatar). 2) put AddExplosionForce script in avatar and position at origin (explosion position set to origin) 3) put translator script in trigger object. Place projectile and trigger anywhere convenient. 4) On the trigger object, put an event trigger (pointer on click) to first translate projectile and a second event to disable kinematic (of the projectile) and a third event to apply AddexplosionForce. 5) play camera (I am using GVR emulator editor but first person player can also be used. 6) Fire trigger event. You will see the projectile is not moving in the correct direction after translation
is$$anonymous$$enamatic is set to false just before the explosion ( rb.AddExplosionForce (power=10, explosionPos=camPos, radius=5, upwards$$anonymous$$odifier=1, force$$anonymous$$ode=Impulse);
Answer by Lysander · Dec 31, 2017 at 05:37 AM
It may have to do with the script execution order, which varies between scripts and projects for no reason at all if it's set to default. You may want to play around with LateUpdate/FixedUpdate timings or add a script to the Script Execution Order list to be sure its always fired first or last to narrow down the specifics of the issue.
If needed, you can check out lordofduct's "SpacePuppy" framework on github, which implements (among many many many other things) a system to reliably do EarlyUpdates- just check out SpacepuppyBase - > GameLoopEntry to see how it works. implementing something like that yourself isn't that difficult if that's the only thing you want to pull from the framework.
Putting AddExplosionForce in LateUpdate solved the problem