ShiVa3D
Dynamic Collision Problem [SOLVED]
All about the StoneScriptDynamic Collision Problem
by MrGamer » 21 Jun 2012, 11:12
My player has a dynamic object attached scaled to 0.1 and when moving at velocity of 18 it sometimes passes through walls and floors with collider enabled. This should not be possible. Looking for solution.
Play game win cash prize
http://moneybackapps.com/
https://play.google.com/store/apps/developer?id=Money+Back+Apps
http://moneybackapps.com/
https://play.google.com/store/apps/developer?id=Money+Back+Apps
Re: Dynamic Collision Problem
by neilb » 21 Jun 2012, 12:51
A couple of things that might help:
1) Colliders don't scale with the object they are attached to, they remain at a scale of 1
2) If an object is moving fast enough it can sometimes "jump over" another object between frames
1) Colliders don't scale with the object they are attached to, they remain at a scale of 1
2) If an object is moving fast enough it can sometimes "jump over" another object between frames
Re: Dynamic Collision Problem
by broozar » 21 Jun 2012, 13:24
walls and floors might have no thickness, so the "jumping over" effect neilb described is easier with those. use boxes, they have a thickness.
Re: Dynamic Collision Problem
by MrGamer » 21 Jun 2012, 16:24
Thanks for your reply
I tried all the way as i can. I made wall with x 100, y = 10, and z=1, i set collider on it in model editor. if i use very slow speed velocity then it works but when i increased my speed then again i am getting same problem. I am using some api function to get information.
now sometimes it return me collision information and sometimes it does not return me anything.
Sometimes it prints more than one message on collision .

I tried all the way as i can. I made wall with x 100, y = 10, and z=1, i set collider on it in model editor. if i use very slow speed velocity then it works but when i increased my speed then again i am getting same problem. I am using some api function to get information.
- Code: Select all
if ( this.hHelperPlayer ( )~=nil )
then
if (dynamics.getLastCollisionContactCount ( this.hHelperPlayer ( ) )>0 )
then
local hObj = dynamics.getLastCollisionContactObjectAt ( this.hHelperPlayer ( ),0)
local sname = object.getModelName (hObj )
if ( string.compare ( sname,"FlatWallComponentLarge" )==0)
then
log.message ( hObj )
local x1,y1,z1 = dynamics.getLastCollisionContactPositionAt ( this.hHelperPlayer ( ), 1 )
-- object.setTranslation ( this.hHelperPlayer ( ), x1,y1,z1,object.kGlobalSpace )
object.resetTranslation ( this.hHelperPlayer ( ), object.kGlobalSpace )
log.message ( x1, " , ",y1, " , ",z1 )
end
end
end
now sometimes it return me collision information and sometimes it does not return me anything.
Sometimes it prints more than one message on collision .
Play game win cash prize
http://moneybackapps.com/
https://play.google.com/store/apps/developer?id=Money+Back+Apps
http://moneybackapps.com/
https://play.google.com/store/apps/developer?id=Money+Back+Apps
Re: Dynamic Collision Problem
by psychicsoftware » 21 Jun 2012, 20:41
did you try increasing the dynamics iterations per step, and/or reducing the dynamics timestep?
scene.setDynamicsIterationsPerStep ( hScene, nIterations )
scene.setDynamicsTimeStep ( hScene, nTimeStep )
scene.setDynamicsIterationsPerStep ( hScene, nIterations )
scene.setDynamicsTimeStep ( hScene, nTimeStep )
-

psychicsoftware - Gold Boarder

- Posts: 284
- Location: Galway, Ireland
Re: Dynamic Collision Problem
by MrGamer » 22 Jun 2012, 06:43
psychicsoftware wrote:did you try increasing the dynamics iterations per step, and/or reducing the dynamics timestep?
scene.setDynamicsIterationsPerStep ( hScene, nIterations )
scene.setDynamicsTimeStep ( hScene, nTimeStep )
Thanks i think it can help me could you tell me how to use it properly. please also could you tell me how much it affect on cpu usage.
Play game win cash prize
http://moneybackapps.com/
https://play.google.com/store/apps/developer?id=Money+Back+Apps
http://moneybackapps.com/
https://play.google.com/store/apps/developer?id=Money+Back+Apps
Re: Dynamic Collision Problem [SOLVED]
by psychicsoftware » 22 Jun 2012, 10:08
I can't recall what the default values are, I think maybe 1/120 for timestep. You can easily find out the defaults by using the scene.getXXX methods corresponding to these.
It will certainly affect CPU, yes. I think the important thing to do is to manage different device capabilities, and for this application.getAverageFrameTime is awesome.
Here's what I have done in one of my apps which has lots of physics objects, in order to support different device capabilities:
You need to start this off by calling it once in your onInit handler. After that, it looks after itself and rechecks every 5 seconds to see if the physics timestep can be changed.
I'm not sure what the difference would be between tweaking timestep versus tweaking iterations per step. From working with open source engines, I would think that either would solve your problem - the difference would be when you need to accurately handle the interactions between multiple physics objects, then timestep is a better solution than iterations.. basically, if I'm right, every timestep each object is moved forward. When being moved forward, each object's movement is integrated over a number of iterations - the larger the number of iterations, the smaller each movement is and hence the less likely that a fast moving object will pass through things.
It will certainly affect CPU, yes. I think the important thing to do is to manage different device capabilities, and for this application.getAverageFrameTime is awesome.
Here's what I have done in one of my apps which has lots of physics objects, in order to support different device capabilities:
- Code: Select all
--------------------------------------------------------------------------------
function LBS_MainAI.onThrottlePhysicsRate ( )
--------------------------------------------------------------------------------
local s = application.getCurrentUserScene ( )
local ft = application.getAverageFrameTime ( )
if ( ft < 1/50 ) then
scene.setDynamicsTimeStep ( s, 1/200 )
elseif ( ft < 1/30 ) then
scene.setDynamicsTimeStep ( s, 1/120 )
else
scene.setDynamicsTimeStep ( s, 1/60 )
end
this.postEvent ( 5, "onThrottlePhysicsRate" )
--------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------
You need to start this off by calling it once in your onInit handler. After that, it looks after itself and rechecks every 5 seconds to see if the physics timestep can be changed.
I'm not sure what the difference would be between tweaking timestep versus tweaking iterations per step. From working with open source engines, I would think that either would solve your problem - the difference would be when you need to accurately handle the interactions between multiple physics objects, then timestep is a better solution than iterations.. basically, if I'm right, every timestep each object is moved forward. When being moved forward, each object's movement is integrated over a number of iterations - the larger the number of iterations, the smaller each movement is and hence the less likely that a fast moving object will pass through things.
-

psychicsoftware - Gold Boarder

- Posts: 284
- Location: Galway, Ireland
7 posts
• Page 1 of 1

