ekograh
September 30, 2021, 8:14am
1
Hello,
First I want to rotate an object and then I want to use LookAT
Do you have idea ?
Tried with following code but didn’t work.
GameObject.FindGameObjectWithTag("PivotR").transform.rotation = Quaternion.FromToRotation(Vector3.right, transform.forward);
GameObject.FindGameObjectWithTag("PivotR").transform.LookAt(target1);
You want to use LookAt with a rotational offset? Because “LooKat” always uses the forward vector (blue axis) to point your transform to the target. You have to multiply the result with a rotation.
try something like:
Transform pivotR = GameObject.FindGameObjectWithTag("PivotR").transform;
pivotR.rotation =
Quaternion.LookRotation(target.position - pivotR.position, Vector3.up) * Quaternion.FromToRotation(Vector3.right, transform.forward);