# How does GetRelativeVector work?

I found some code online for a simple 2D car movement script. However, I want to understand WHY it works the way it does so I can make tweaks to it. I’m particularly confused with ‘GetRelativeVector’:

``````float direction = Vector2.Dot(rb.velocity, rb.GetRelativeVector(Vector2.up));
if(direction >= 0.0f) {
rb.rotation += h * steering * (rb.velocity.magnitude / 5.0f);
//rb.AddTorque((h * steering) * (rb.velocity.magnitude / 10.0f));
} else {
rb.rotation -= h * steering * (rb.velocity.magnitude / 5.0f);
//rb.AddTorque((-h * steering) * (rb.velocity.magnitude / 10.0f));
``````

(where ‘rb’ is an instance of Rigidbody2D).
Here’s what the manual says:

As far as I can tell, Vector2.up is just synonymous to a simple vector (0,1). And this vector is the ‘local space vector’ argument. So what would rb.GetRelativeVector(Vector2.up) be?

That exact equation `rb.GetRelativeVector(Vector2.up)` looks like it’s simply getting the [EDITS: xxforwardxx – opps, UP] unit vector. [xxIt turns out there’s no easier way to get thatxx]. rb.rotation is a special 0-360 float. It seems to work independently of rb.transform. An easy shortcut to spin rigibbodies (I don’t know 2D – not sure why regular 2D sprites have to use a 3D rotation).

All rb.GetRelativeVector does is spin the input by -rotation degrees. If rotation is 90, it turns (5,0) into (0,5).