- Home /
Vector3.Slerp
Can anyone tell me what is wrong with this?
Camera.main.transform.position = new Vector3.Slerp (-38f, 6f, -10f);
Comment
Answer by Alpha_Guac · Oct 30, 2015 at 01:27 PM
Make sure you know the difference between Slerp and lerp, they are quite similar yet affect objects differently. here is are some functions that I used to swing a sword.
//functions takes in two vector3's (the strart position and end position) and the rigidbody that is rotating
//currentTime and speed are both floats that determine how long it takes to rotate the object
void SwingDown(Vector3 startpos,Vector3 endpos,Rigidbody rb)
{
rb.transform.eulerAngles = (Vector3.Lerp(startrot,endpos, currentTime / speed));
}
void SwingReturn(Vector3 startrot,Vector3 endpos,Rigidbody rb)
{
rb.transform.eulerAngles = (Vector3.Lerp(startrot, endpos + new Vector3(0, 120), currentTime / speed));
}
I hope this gives you an idea of what this Vector3 function can do. As a side note the currentTime variable was equal to deltaTime and was reset after each function was used.