mardi 6 janvier 2015

How do I calculate relative velocity?


Based on a single Y rotation (Rot) of an object on the XZ plane and its relative velocity (RelVol), how can I calculate what to translate its position (Pos) by?


So I.e. Using Unity's standard vector libraries



Vector2 Pos = Vector2.zero; //(0,0)

Vector2 RelVol = new Vector2 (0,1); //(0,1)

float Rot = 90; //90 Euler degrees

void Update()

{

Vector2 RealVelocity = MethodForCalculations (RelVol); //Calculates based on relative velocity and angle

Pos += RealVelocity; //Changes position based on relative velocity and angle

}

Vector2 MethodForCalculations (Vector2 RelVol)
{
//This is what I need help with
}


In this example, I'd like RelativeVelocity to be (1,0) because the object is now facing right. Thus, its Y velocity directly affects the X translation. How do I calculate the real velocity for any relative velocity and angle?





Aucun commentaire:

Enregistrer un commentaire