
[ad_1]
I’m attempting to create the door that’s triggered by the participant in an FPS recreation.
I am unable to determine easy methods to make the door rotate solely on y-axis. I would like the door to be triggered by the participant, however nonetheless keep on the y axis on the identical time. Instead my code is making the door rotate on all angles in direction of the goal.
public class DoorController : MonoBehaviour
{
public GameObject Door;
public GameObject participant;
public bool isOpen;
public float rotationSpeed;
non-public Transform goal;
non-public Quaternion lookRotation;
non-public Vector3 course;
//public float moveSpeed;
void Update()
{
if (isOpen)
{
goal = participant.rework;
course = (goal.place - rework.place).normalized;
lookRotation = Quaternion.LookRotation(course);
rework.rotation = Quaternion.Slerp(rework.rotation, lookRotation, Time.deltaTime * rotationSpeed);
}
}
void OnTriggerEnter(Collider different)
{
isOpen = true;
}
void OnTriggerExit(Collider different)
{
isOpen = false;
}
}
```
[ad_2]