So I'm using this code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class wands : MonoBehaviour
{
public Transform WandPos;
void Update()
{
WandPos.rotation = Quaternion.Lerp(new Quaternion(0,0,1,0), new Quaternion(0,0,0.866025448f,0.49999994f),Time.time * .5f);
}
}
For some reason it is preforming the rotation before the GameObject even rotates, so when it instantiates, the GameObject snaps to where it would be if it instantiated when the scene started. I'm probably just missing something obvious, but I can't seem to find my solution anywhere online either.
Also, if there is an easier way to do this than with the code I've written, please tell me.
CodePudding user response:
Well Time.time
is the time in seconds since you started the application!
Sounds like you rather wanted to track the time since you instantiated the object so e.g. like
private float time;
void Update ()
{
time = Time.deltaTime * 0.5f;
WandPos.rotation = Quaternion.Lerp(new Quaternion(0,0,1,0), new Quaternion(0,0,0.866025448f,0.49999994f), time);
}