I’m trying to set objects with the tag “chair” to their original rotation once they are picked up.
Here is what I tried to do:
if (currentlyPickedUpObject != null)
{
if (currentlyPickedUpObject.tag == "chair")
{
lookRot = Quaternion.LookRotation(mainCamera.transform.position - pickupRB.position);
lookRot = Quaternion.Slerp(mainCamera.transform.rotation, lookRot, rotationSpeed * Time.fixedDeltaTime);
//pickupRB.MoveRotation(lookRot);
Vector3 angles = new Vector3(-90, 0, pickupRB.transform.eulerAngles.z);
pickupRB.transform.rotation = Quaternion.Euler(angles);
}
reticle.enabled = false;
}
but this doesn’t work well for all the chairs in the scene, some are working and some of them get roatated in a different way.
.
I want all of the object with this tag to get their original rotation when the player picks them up. some secnes have one chair and others have two or more. so If there is a way to do the rotation automatically without me seting the number of chairs and their orginal vlaues, it would be super useful. please help