You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.3 KiB
C#
57 lines
1.3 KiB
C#
1 year ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class DoorAnimation : MonoBehaviour
|
||
|
{
|
||
|
// Start is called before the first frame update
|
||
|
|
||
|
public int CurrentAction = 0;
|
||
|
public int TimeRotation = 0;
|
||
|
public float AngleRotation = -0.1f;
|
||
|
public bool DoorIsMoving = false;
|
||
|
[SerializeField]
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public void OpenDoor() {
|
||
|
CurrentAction = 1;
|
||
|
}
|
||
|
|
||
|
public void CloseDoor() {
|
||
|
CurrentAction = 2;
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
if(CurrentAction == 1) {
|
||
|
if(TimeRotation < 900) {
|
||
|
TimeRotation += 1;
|
||
|
DoorIsMoving = true;
|
||
|
transform.Rotate(0, 0, AngleRotation);
|
||
|
}
|
||
|
else {
|
||
|
DoorIsMoving = false;
|
||
|
CurrentAction = 0;
|
||
|
TimeRotation = 0;
|
||
|
}
|
||
|
}
|
||
|
else if(CurrentAction == 2) {
|
||
|
if(TimeRotation < 900) {
|
||
|
TimeRotation += 1;
|
||
|
DoorIsMoving = true;
|
||
|
transform.Rotate(0, 0, -AngleRotation);
|
||
|
}
|
||
|
else {
|
||
|
DoorIsMoving = false;
|
||
|
CurrentAction = 0;
|
||
|
TimeRotation = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|