Jump to content

PlayerActor on movable platform


photo

Recommended Posts

I've been trying to figure out how to do this by looking (and modifying) the samples, but so far no luck. Basically we want the actor to be able to move around on an object that is moving through the scene. This works on fully physical objects, like a BodyRigid that was moving up/down using forces and a JointPrismatic,but this method of course requires complete setup of shapes, joints and simulation of forces to work, which we don't want to do for all objects. For most cases we would prefer simply moving the object around, but then the player does not stick to the surface but slides along it until it falls off when reaching the edge. Parenting the actor to the surface did work a bit, but it started shaking, rotating 180 degrees every frame. Also it would require dynamic parenting/unparenting when the player leaves the object.

 

So none of the methods I tried was ideal. Is there a better way to approach it? And are there any samples that I overlooked that feature a player on a movable object (ship, car) that isn't statically parented but can still walk around the moving surface?

Link to comment

Bemined,
 
Unfortunately, there is no right way to do it. 
 

Parenting the actor to the surface did work a bit, but it started shaking, rotating 180 degrees every frame.

 

That can be partially solved by disabling physics for PlayerActor (setPhysical(0) method) while it on a moving platform. In that case you can move PlayerActor mathematically. Also you need to store phi and theta angles before setWorldParent and platform move and restore them after:

float phi = actor->getPhiAngle();
float theta = actor->getThetaAngle();

platform->translate(...)

actor->setPhiAngle(phi);
actor->setThetaAngle(theta);

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...