Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sat Oct 28, 2017 1:27 pm 
Offline

Joined: Tue Jul 18, 2017 7:48 pm
Posts: 10
Hey all,

I'm trying to make a moving platforms in my game. I want them to be able to:

- follow a path with constant speed,
- move the objects that are placed on top of it.

Currently my moving platforms are implemented as a kinematic object that gets it's position updated via setWorldTrasnform().
In order to implement the "moving object that are on the platform" I think I need to take the velocity of the platform and then apply it to the objects that are sitting on top of it. However I cannot use the setLinearVelocity() as there is practically none for the kinematic objects. Is there a way to extract the velocity (I guess not)?

I'm not sure if this implementation would work. All suggestions are welcome.

EDIT:

Is there a way to implement my platforms with a dynamic object?


Top
 Profile  
 
PostPosted: Sat Oct 28, 2017 7:59 pm 
Offline
User avatar

Joined: Tue Sep 30, 2014 6:03 pm
Posts: 363
Location: San Francisco
You're supposed to set the velocity of the kinematic object too. Set it to whatever its real velocity should be. Also, don't forget to make sure it is active so it can activate nearby dynamic objects.

Bullet will collide kinematic objects and their velocities will affect other objects, but kinematic objects are not affected and Bullet doesn't perform motion integration on them: it expects external code to update kinematic positions.


Top
 Profile  
 
PostPosted: Sun Oct 29, 2017 5:09 pm 
Offline

Joined: Tue Jul 18, 2017 7:48 pm
Posts: 10
Thanks, setting the linear velocity really works!
the problem I've got now is that the kinematic object now accelerates the rigid bodies, but I want it to just move them for this step() call only?


Top
 Profile  
 
PostPosted: Mon Oct 30, 2017 12:37 am 
Offline
User avatar

Joined: Tue Sep 30, 2014 6:03 pm
Posts: 363
Location: San Francisco
Dunno what is the new problem. If I had to guess I would say: it sounds to me like the linear velocity of the kinematic object is too high for its true motion. You calculated it wrong.


Top
 Profile  
 
PostPosted: Mon Oct 30, 2017 8:02 pm 
Offline

Joined: Tue Jul 18, 2017 7:48 pm
Posts: 10
The velocity seems file (it is pretty straight forward).
I guess this gif will express what I mean. When the platform goes all the way up and stops, the box continues to go upwards. I guess the box gained momentum during the elevation.

Oh and one next thing. The platform goes down faster than the gravity, and again I want the box to be pulled by the platform downwards.


Attachments:
2017-10-30_21-56-49.gif
2017-10-30_21-56-49.gif [ 168.42 KiB | Viewed 428 times ]
Top
 Profile  
 
PostPosted: Mon Oct 30, 2017 8:48 pm 
Offline
User avatar

Joined: Tue Sep 30, 2014 6:03 pm
Posts: 363
Location: San Francisco
I see. Yes, the dynamic crate picks up velocity from the kinematic platform.

What you want may be outside the bounds of a physically correct simulation. That's fine, game physics is often cheated to make things fun or to get effects just right, but there is no fundamental feature of kinematic or dynamics motion that will provide exactly what you want. Depending on the solution you pick you might have to add very custom code.

I've got a few ideas on how to go forward. I offer them in case they are helpful:

(1) When animating the platform don't allow it to start/stop with high acceleration. Always accelerate its motion at a rate that is less than whatever is the acceleration of gravity. In short: platform velocity transitions should follow an s-curve where the slope of the curve is never steeper than gravity itself.

(2) Artificially increase the gravity of objects on kinematic platforms. This will reduce the height/duration of the hops but the problem will nevertheless persist if you continue to have arbitrarily high instantaneous acceleration of the platform.

(3) Slam the velocity of objects on platforms whenever the platforms start/stop. This would work if you happen to always know when CrateA is on PlatformB. You'd only have to slam CrateA's velocity when the platform actually accelerates. During its constant linear motion phase the crate should already have the approximately correct velocity.


Top
 Profile  
 
PostPosted: Mon Oct 30, 2017 9:02 pm 
Offline

Joined: Tue Jul 18, 2017 7:48 pm
Posts: 10
Thanks a lot for the suggestions I'll give them a try!

Meanwhile I've played a bit. Instead of adding velocity to the kinematic object, I track all objects that are touching it, and forcefully update their transform via setWorldTransform(). At 1st glance this works at 85%.

This currently happens after the call to stepSimulation(), I guess I can move it in btActionInterface. This *solution* still needs a lot of testing and corner case fixing. I'll post an update if I gain any progress.

EDIT: This thing that I said is not true: "form time to time the objects on the platform *jitter* because on the current frame they collide with the object and on the next they don't for some reason." The reason why the characters bumps/jitters is because it is a dynamic body that tries to fight the physics and add velocities in order control it's movement.


Attachments:
2017-10-30_22-56-25.gif
2017-10-30_22-56-25.gif [ 218.91 KiB | Viewed 425 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 21 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:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group