I have created a simple example where I have a small “floor” with a wall around it to stop the player “falling off” - my carpetNode.
I am using a RigidBodyControl for the carpetNode, and have added it to a BulletAppState.
I have a “player” based on a BetterCharacterControl with a camera attached who can move about on the floor.
Thus far everything works … if I jump over a wall and off the carpet I fall down.
What I want to be able to do is move the carpetNode. When I do a simple carpetNode.move(x,y,z) the carpet node moves off. The 1st problem is that when the playerControl is no longer on the carpet he does not fall down.
The 2nd problem concerns the playerCOntrol: I have tried to move the playerControl using the set walkDirection to be the same as the translation I have given to the carpet … but the carpet moves and the playerControl does not.
I am obviously doing something wrong but just can’t figure it out!
Without any code, it will be hard to tell to you what is wrong. Also, when the carpet move, if the player jump (without moving, just jump) what happened then ? Did he fall ? Or just “fall” to the place where is was, in the air ? I am asking this question because the bullet engine has the notion of “sleeping object” i.e. when an object doesn’t move or interact with something the bullet engine just disable all the physics stuff related to this object.
If the “move” method doesn’t actually move the carpet but teleport it, it’s possible that the physic engine doesn’t notice that the player should fall.
If the bug is there, we will only need to find how “reactivate” the player each time the carpet move.
@bubuche said:
Without any code, it will be hard to tell to you what is wrong. Also, when the carpet move, if the player jump (without moving, just jump) what happened then ? Did he fall ? Or just "fall" to the place where is was, in the air ? I am asking this question because the bullet engine has the notion of "sleeping object" i.e. when an object doesn't move or interact with something the bullet engine just disable all the physics stuff related to this object.
If the "move" method doesn't actually move the carpet but teleport it, it's possible that the physic engine doesn't notice that the player should fall.
If the bug is there, we will only need to find how “reactivate” the player each time the carpet move.
Hi bubuche, Thanks for the reply, I do not have the code with me right now and will post it tomorrow.
However I think you maybe on the right lines… When the carpet has moved and the player moves he is restricted as if the carpet still there. If he jumps it is the same.
I may be incorrect but the way I read your question:
“I have a physics object and then I move the visual representation of it but not the physics objects and then the physics object acts like it hasn’t moved.”
Translated closer to what you actually said:
“I have a RigidBodyControl and then I move the Node but not the RigidBodyControl and then the RigidBodyControl acts like it hasn’t moved.”
Perhaps the issue seems more obvious in that light?
@pspeed said:
I may be incorrect but the way I read your question:
"I have a physics object and then I move the visual representation of it but not the physics objects and then the physics object acts like it hasn't moved."
Translated closer to what you actually said:
“I have a RigidBodyControl and then I move the Node but not the RigidBodyControl and then the RigidBodyControl acts like it hasn’t moved.”
Perhaps the issue seems more obvious in that light?
Okay I think I have got it now … I have just had a look at the HelloPhysics example with the cannonballs… What I need to do is set the linear velocity of the phsics object which will move update the RigidBody aswell as the Geometry.
no, you only need to move the rigidbodycontrol, it should move itself the geometry. This is only true if you used the “addControl” method, of course.
Also, note that the character will iikely not move with the plateform (it was true for the charactercontrol, i don’t know for the bettercharactercontrol). To move both of them together, there is a lot of tricks.
Ok, i never went this way myself, but this is small “part of solution”.
1 - i heard something about having a “physic space dedicated to the plateform” but i don’t exactly know what is means.
2 - this solutions is a bit more easy : you have to store in the charactercontrol (subclass it?) the actual location of the SUPPORT of your player. For exemple, when you are not on a moving plateform, this support doesn’t move, it’s for exemple the rootnode or, better, the “physic object under the player”. When you walk on a moving plateform, you just update this reference.
This alone doesn’t change anything. But now, you can know where your player is, so every physics tick, you can move your player to match the movement of the plateform beneath him. This will become a bit harder if you don’t have the same gravity everywhere.
Note also that when you move the player like this, you need to use “warp” which can have a side effect : if you wanted to have the “the plateform go in a breach in the wall and the player fall because of this” it will not work : when you warp a character, you WARP it, not move it. So, there is no “movement”, so no “movement recovery” from the physic engine). But as long as you just use it to go from a place to an other it should do it.