Hi,
In the video below
you can see that every time I move the character forward, it moves a bit to the direction of the moving platform
Does anyone know if I can avoid this?
Here is how I create the player:
pControler = Pivot::Create();
pControler->SetPhysicsMode(Entity::CharacterPhysics);
pControler->SetMass(1.0);
pControler->SetPosition(pEntity->GetPosition(true));
pEntity->SetParent(pControler, true);
pEntity->SetPosition(0.0, getHeight(), 0.0);
pEntity->SetShape(NULL);
pEntity->SetMass(0.0);
and here is how I create the platform:
std::string szVal;
Vec3 origin;
Vec3 distance;
origin = pEntity->GetPosition(true);
distance.x = std::atof(pEntity->GetKeyValue("Dx", "").c_str());
distance.y = std::atof(pEntity->GetKeyValue("Dy", "").c_str());
distance.z = std::atof(pEntity->GetKeyValue("Dz", "").c_str());
bEnabled = (bool)std::atoi(pEntity->GetKeyValue("Enabled", "").c_str());
pEntity->SetShadowMode(2);
pEntity->SetGravityMode(false);
pEntity->SetCollisionType(Collision::Prop);
pEntity->SetMass(1.0);
pJoint = NULL;
SetTarget(origin, origin + distance);
The SetTarget function:
Vec3 pin;
mOrigin = origin;
mTarget = target;
mDistance = mTarget - mOrigin;
if (pJoint)
{
pJoint->DisableMotor();
pJoint->Release();
}
pin = mDistance.Normalize();
pJoint = Joint::Slider(mOrigin.x, mOrigin.y, mOrigin.z, pin.x, pin.y, pin.z, pEntity, NULL);
pJoint->EnableMotor();
pJoint->SetMotorSpeed(2.0);
pJoint->SetTargetAngle(mDistance.Length());