I have a little problem with maxspeed for gravity...
You see, this is really simple. I set gravity to -10, and created some BoxShapes.
In Update method i'm taking all collistionObjects from DynamicsWorld and setting Y to orginal height if is larger then value. It works fine, and object appears on the top of another object, but it has his old speed which is growing because of gravity... I have tried to set InterpolationLinearVelocity to vector e.g. 1,1,1 but without luck..
Code: Select all
public virtual void Update(float elapsedTime)
{
foreach (CollisionObject collisionObject in World.CollisionObjectArray)
{
if (collisionObject.UserObject.ToString() == "ball")
{
//put object on the top of the other object.
if (collisionObject.WorldTransform.Translation.Y < -10)
{
Random rand = new Random();
float start_x = rand.Next(-(Convert.ToInt32(Math.Ceiling(wx))), Convert.ToInt32(Math.Ceiling(wx / 2)));
Matrix startTransform = Matrix.CreateTranslation(new Vector3(start_x,2 * wy,(float)-2.55));
collisionObject.WorldTransform = startTransform;
}
//Reset speed. Set speed i.e. to 20 or something.... it doesn't work and i don't know why :(
//Vector3 maxSpeed = new Vector3(20, 20, 1);
// collisionObject.InterpolationLinearVelocity = maxSpeed;
}
}
World.StepSimulation(elapsedTime);
}
Thanks