GetPositionAfterTime
Introduction
Code Example
// Assume MyCharacter is a valid PositionedObject (like an Entity from Glue)
double timeInSeconds = 1; // how far into the future to calculate the movement
Vector3 positionAfterTime = MathFunctions.GetPositionAfterTime(
ref MyCharacter.Position,
ref MyCharacter.Velocity,
ref MyCharacter.Acceleration,
timeInSeconds);Code Example - Determining Stopping Distance
var timeToSlowDown = 3;
var maxSpeed = player.MaxSpeed;
var accelerationValue = -maxSpeed/timeToSlowDown;
// create the temporary vectors:
var position = new Vector3(0,0,0);
var velocity = new Vector3(maxSpeed, 0,0);
var acceleration = new Vector3(accelerationValue, 0,0);
var positionAfterTime = MathFunctions.GetPositionAfterTime(
ref position,
ref velocity,
ref acceleration,
timeToSlowDown);
var stoppingDistance = positionAfterTime.X;Last updated
Was this helpful?