For example I have an object that I want to move at 45 degrees upwards. How do I get the vector coords that I need to push the object at?
Thanks
-
I want to MOVE the object. Not rotate, MOVE IT. So it moves diagonally 45 degrees.
45 degrees is just an example, I need to find how to convert from angle to vector. I do not want to rotate it, just move.
Bobadebob is right. Everything that involves rotations/angles you need a Quaternion. Just create a quaternion that rotates 45 upwards and multiply your vector2 with it to rotate the direction.
var rot = Quaternion.AngleAxis(45,Vector3.right);
// that's a local direction vector that points in forward direction but also 45 upwards.
var lDirection = rot * Vector3.forward;
// If you need the direction in world space you need to transform it.
var wDirection = transform.TransformDirection(lDirection);
You can of course set up the vector the old, traditional way :D. Just some trigonometry (that's the day your math teacher was talking about)
var angle = 45.0;
var lDirection = Vector3(0, Mathf.sin(Mathf.Deg2Rad * angle), Mathf.cos(Mathf.Deg2Rad * angle));