Hello,
I'm working on a marble game. And I plan to have moving platforms in my game.
Platforms would go to certain points, the position and rotation would be calculated manually.
What I want to achieve is that the player(sphere) or any other dynamic rigid body would get affected by the movement of platform, and move accordingly with it.
How would I achieve this?
Manually moving platforms.
-
dphil
- Posts: 237
- Joined: Tue Jun 29, 2010 10:27 pm
Re: Manually moving platforms.
From what I understand, dynamic objects can move around and cause collisions and also have their motion affected by collisions. Static objects do not move and are not affected by collisions, but dynamic and kinematic objects can collide with them. Kinematic objects are kind of in the middle. Their motion is not affected by things colliding with them, but they can be moved manually (by the user/program) and dynamic and other kinematic objects collide with them.
So I think if you make your platform a kinematic object, it should do what you want. It won't be affected by characters/etc jumping on it, but it can lift them up/down by manually moving it with your own code.
So I think if you make your platform a kinematic object, it should do what you want. It won't be affected by characters/etc jumping on it, but it can lift them up/down by manually moving it with your own code.
-
serengeor
- Posts: 22
- Joined: Mon Dec 20, 2010 7:13 pm
Re: Manually moving platforms.
Actually all of my objects will be non kinematic objects, including platforms. I Know how to get my platform not affected by other physics bodies too. But what I need is that when I move my platform, the other objects on top of it should move accordingly.
EDIT: from what I've read it seams that I will have to move objects that are on platform manually too.
Maybe there are other ways to do this?
EDIT: from what I've read it seams that I will have to move objects that are on platform manually too.
Maybe there are other ways to do this?
-
Nickeeh
- Posts: 14
- Joined: Wed Feb 09, 2011 8:35 pm
Re: Manually moving platforms.
Objects on my platforms are moving accordingly (balls will "want" to stay in their original position, but roll on it). This is done by having a ball with a mass of 1 and everything else default. Place it on top of a kinematic object, move the kinematic object, and you'll get a realistic reaction of the sphere on the platform. You don't get that?
-
serengeor
- Posts: 22
- Joined: Mon Dec 20, 2010 7:13 pm
Re: Manually moving platforms.
Hm, sounds good, what exactly do you use to move your kinematic object? transform, or just setPosition ?Nickeeh wrote:Objects on my platforms are moving accordingly (balls will "want" to stay in their original position, but roll on it). This is done by having a ball with a mass of 1 and everything else default. Place it on top of a kinematic object, move the kinematic object, and you'll get a realistic reaction of the sphere on the platform. You don't get that?
Also my platforms should float in air(not affected by gravity),
-
Nickeeh
- Posts: 14
- Joined: Wed Feb 09, 2011 8:35 pm
Re: Manually moving platforms.
Don't have the code at the moment, but it's a normal kinematic body (look at the wiki for a hint or two how they work with motionstates, which will also answer your question about how to set their position correctly), and a "default" sphere, default gravity.
-
serengeor
- Posts: 22
- Joined: Mon Dec 20, 2010 7:13 pm
Re: Manually moving platforms.
Okay I'll have a look when I get time to do so and will report here.Nickeeh wrote:Don't have the code at the moment, but it's a normal kinematic body (look at the wiki for a hint or two how they work with motionstates, which will also answer your question about how to set their position correctly), and a "default" sphere, default gravity.