Object Stacking Without the Jitters
by Dustin Sims · in Torque Game Builder · 07/28/2007 (8:56 pm) · 5 replies
I am trying to stack about 10 objects on top of each other as they are falling towards the ground. All the objects are the same and each has a ConstantForceY pushing them down.
I have ran in to a problem because eventually they all start jittering.
My game design needs to be able to check each of the objects and know when each has stopped moving. I am currently checking the .isAtRest field of the objects and it works pretty well until objects started jittering. I have also checked the YVelocity and they seem to start jittering with velocity values coming in at 0 o 7...
Is there anyway to keep this from happening and be able to rely solely on the built in physics to make this work.
I would like all objects just come to a rest and sit still?
I have ran in to a problem because eventually they all start jittering.
My game design needs to be able to check each of the objects and know when each has stopped moving. I am currently checking the .isAtRest field of the objects and it works pretty well until objects started jittering. I have also checked the YVelocity and they seem to start jittering with velocity values coming in at 0 o 7...
Is there anyway to keep this from happening and be able to rely solely on the built in physics to make this work.
I would like all objects just come to a rest and sit still?
#2
If I set the objects immovable after they stop then what do I do when the objects underneath dissapear or get moved by the player (Which is part of the game play).
My earlier solution to this was to iterate through every object on screen that was immovable and test the area underneath it for objects to see if it needed to start moving again.
Doing this in script seemed to make game noticibly sluggish once I had alot of objects on the screen at one time.(about 120 max that would have to be checked on a very tight schedule so that objects would react realisticly)...
Is there a better/faster way than this..
I used a For Loop and checked every object on screen..
Maybe I will script again and see if I can make it work better..
Could I write a behavior that tests constantly on the OnUpdate() and locks object when there is another beneath it and unlocks it when there is not an object underneath?
07/29/2007 (6:46 pm)
I have tried that exact thing a while back and maybe I can go back to that solution if I can come up with a way around the problems that it introduces..If I set the objects immovable after they stop then what do I do when the objects underneath dissapear or get moved by the player (Which is part of the game play).
My earlier solution to this was to iterate through every object on screen that was immovable and test the area underneath it for objects to see if it needed to start moving again.
Doing this in script seemed to make game noticibly sluggish once I had alot of objects on the screen at one time.(about 120 max that would have to be checked on a very tight schedule so that objects would react realisticly)...
Is there a better/faster way than this..
I used a For Loop and checked every object on screen..
Maybe I will script again and see if I can make it work better..
Could I write a behavior that tests constantly on the OnUpdate() and locks object when there is another beneath it and unlocks it when there is not an object underneath?
#3
08/08/2007 (7:32 pm)
You could try storing the ID of the object above in a property of the object below, or even both above and below. Then when an object is removed in the stack, it checks to see if the object ID it has stored is still existing, and sets it moveable... When that object above is set moveable it also checks to see if it has an ID stored of an object above it, and does the same etc.
#4
11 days with no new posts...
That is a very neat idea.
I am still working on this and was trying to get my code "ported - - per say'" over to behaviors and try that
approach.
I definately like your idea and that gives me some things to try...
08/09/2007 (7:02 pm)
I had almost thought everyone had abandoned the "Collisions and Physics" section of the forums...11 days with no new posts...
That is a very neat idea.
I am still working on this and was trying to get my code "ported - - per say'" over to behaviors and try that
approach.
I definately like your idea and that gives me some things to try...
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
make them immovable when they are "isAtRest" to prevent "reactions" on other objects that already created pushing forces onto them and therefor lead to a reaction even thought they might not be pushing anymore.
if you need real rest in the physics simulation then you will need to alter the system or fully replace it ...