Box2D Forums

It is currently Sat May 18, 2013 12:50 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Feb 10, 2012 5:32 am 
Offline

Joined: Fri Feb 10, 2012 4:58 am
Posts: 1
Hi all,

I have a platform and an object at rest on top of it. The platform is a static object. They both go to sleep as expected. When I move the platform horizontally (by setting it's position directly) the platform wakes. However the object which is resting upon it doesn't. The platform can slide out of the way without any effect on the object and as it is still asleep, when the platform has moved out of the way the object doesn't fall.

A second instance of this occurs with a sliding platform and a ball on a slight slope. The ball rolls into the platform and comes to rest. They both sleep. The platform wakes and slides to push the ball, but instead passes through the ball. If the ball comes to rest without touching the platform the platform then wakes the ball. I.e. it is only objects that are touching that don't wake each other, I'm guessing because there is no new contact created when the static object moves.

I know I could manually wake the other object but I would prefer if this happened automatically. Is there any settings or specific methods I'm missing for this to happen?


Top
 Profile  
 
PostPosted: Sat Feb 11, 2012 1:27 am 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
In general, moving a body by modifying the positions directly tends to produce some undesired results in the physics. While working on my game, I had encountered problems with sleeping bodies and them not waking up, even when you change their position directly.

It seems like you're moving the static bodies by changing their positions directly to produce a sliding effect while keeping the platforms completely sturdy, uninfluenced by any force. If you want a moving platforms that are not influenced by any other body, use the kinematic setting (b2Body.b2_kinematicBody) instead of static when you're defining the body definition and use SetLinearVelocity() to move the platforms. The kinematic bodies do not collide with static or other kinematic bodies and they are not influenced by gravity forces or any other forces. They do not change velocity until you use SetLinearVelocity() again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group