Collision "lag"
by Marton Gyorgy · in Torque Game Engine · 07/30/2011 (11:34 am) · 6 replies
I am spawning a static shape while playing but for a few seconds my player does not collide with it. Then it starts working as expected. Could someone tell me why?
About the author
#2
I.e. every tick, check all relevant elements (players, etc.), but only force a phycics update when the object is "dirty". The flag would get reset in the physics advance, so that the object doesn't get advanced twice on frames where the physics sim happens to be doing a global udpdate.
You'd obviously need some addition code logic to set the flag in the first place, e.g. when certain types of objects are spawned, etc.
07/31/2011 (12:44 pm)
What about adding a bool used as "dirty" flag, to force the update under certain configurations?I.e. every tick, check all relevant elements (players, etc.), but only force a phycics update when the object is "dirty". The flag would get reset in the physics advance, so that the object doesn't get advanced twice on frames where the physics sim happens to be doing a global udpdate.
You'd obviously need some addition code logic to set the flag in the first place, e.g. when certain types of objects are spawned, etc.
#3
1. Added a console method "forceWorkingCollisionSetUpdate" that updates the collision set without conditions.
2. Make a radius search and call this function on all player objects
It seems to work, so radius search finds player, function called but when I step on the new static shape, my player starts to bounce up and down. This only happens if I call my forceWOrkingCollisionSetUpdate function even if I call it only once, after not moving my static shape anymore. Seems like collision changing constantly but mCollisionCount is always null.
And if the usual updateWorkingCollisionSet happens after moving far enough, collision works as normal and no bouncing happens.
Any ideas?
08/01/2011 (1:07 am)
Thank you for your answers. I am trying to solve this with forcing a working collision set update like this:1. Added a console method "forceWorkingCollisionSetUpdate" that updates the collision set without conditions.
2. Make a radius search and call this function on all player objects
It seems to work, so radius search finds player, function called but when I step on the new static shape, my player starts to bounce up and down. This only happens if I call my forceWOrkingCollisionSetUpdate function even if I call it only once, after not moving my static shape anymore. Seems like collision changing constantly but mCollisionCount is always null.
And if the usual updateWorkingCollisionSet happens after moving far enough, collision works as normal and no bouncing happens.
Any ideas?
#4
08/01/2011 (3:36 pm)
Is this high-frequency messed-up looking bounding, or smooth bouncing as if you're constantly making mini jumps? You might need to ensure that the forced update happens on the client as well as the server. I reckon what might be happening is that the client thinks it should be falling (didn't get the collision update), but the server keeps correcting it.
#5
08/01/2011 (4:20 pm)
Yes, the messed-up looking bouncing. How can I make sure that the forced update happens on the client as well? I could not see any check like isServerObject() in the updateWorkingCollisionSet() code.
#6
-Server object forced to update collision
-Server object calls setMaskBits to indicate its client-side version needs to be updated
-packUpdate happens
-On the client, unpackUpdate happens
-Client does what it needs to do based on the information in the packet
08/02/2011 (7:11 am)
updateWorkingCollisionSet() is called in processTick, which is called both on the client and server, so it is assumed to happen when necessary. What you'll have to do is either create a new mask bit (see calls to setMaskBits) or hijack an existing one for your collision update. The basic idea is:-Server object forced to update collision
-Server object calls setMaskBits to indicate its client-side version needs to be updated
-packUpdate happens
-On the client, unpackUpdate happens
-Client does what it needs to do based on the information in the packet
Torque Owner Daniel Buckmaster
T3D Steering Committee
I suspect this is what you're seeing - if you spawn your shape close to the Player, then it is not included in the collision data until the Player moves sufficiently far away for the set to be updated.
It's a tricky problem to solve. I remember when working on terrain deformation that a way to solve this was basically to do a radius search for all Players in the area when something is modified, and force them to update their collision set. A simpler approach would be to make the Player update their collision data every tick, but this entails a performance hit.