Update Door Animation from Frame to Time

main
CDuong 1 year ago
parent c7b6997554
commit b04abe1cd9

@ -46,6 +46,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
Name: {fileID: 2155252081681785822}
Val: 0
--- !u!1 &3022990752737702646
GameObject:
m_ObjectHideFlags: 0
@ -384,7 +385,9 @@ MonoBehaviour:
m_EditorClassIdentifier:
CurrentAction: 0
TimeRotation: 0
AngleRotation: -0.1
AngleRotation: -160
TimePassed: 0
SumAngleRotate: 0
DoorIsMoving: 0
--- !u!1 &7115776030973179702
GameObject:
@ -397,7 +400,6 @@ GameObject:
- component: {fileID: 2754178639470773891}
- component: {fileID: 4448167961109024055}
- component: {fileID: 1694139564342029656}
- component: {fileID: 1574267693367435642}
m_Layer: 0
m_Name: Cabinet
m_TagString: Untagged
@ -638,6 +640,10 @@ PrefabInstance:
propertyPath: m_Name
value: Cabinet
objectReference: {fileID: 0}
- target: {fileID: 5298247443101524516, guid: fc03c732175eadc47933eb633f615c6b, type: 3}
propertyPath: AngleRotation
value: -160
objectReference: {fileID: 0}
- target: {fileID: 5556232703678627886, guid: fc03c732175eadc47933eb633f615c6b, type: 3}
propertyPath: m_RootOrder
value: 0
@ -685,24 +691,5 @@ PrefabInstance:
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 5066660185504488084, guid: fc03c732175eadc47933eb633f615c6b, type: 3}
insertIndex: -1
addedObject: {fileID: 1574267693367435642}
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: fc03c732175eadc47933eb633f615c6b, type: 3}
--- !u!114 &1574267693367435642
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7115776030973179702}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ed4044aee80d39a4fa934c51059b8e5d, type: 3}
m_Name:
m_EditorClassIdentifier:
CurrentAction: 0
TimeRotation: 0
AngleRotation: -0.1
DoorIsMoving: 0

@ -9,12 +9,12 @@ public class DoorAnimation : MonoBehaviour
[SerializeField]
public int CurrentAction = 0;
public int TimeRotation = 0;
public float AngleRotation = -0.1f;
public float AngleRotation = -160.0f, TimePassed = 0.0f;
public bool DoorIsMoving = false;
void Start()
{
}
public void OpenDoor() {
@ -29,27 +29,31 @@ public class DoorAnimation : MonoBehaviour
void Update()
{
if(CurrentAction == 1) {
if(TimeRotation < 900) {
TimeRotation += 1;
if(TimePassed < 1.0f) {
float NewTime = Mathf.Min(1.0f - TimePassed, Time.deltaTime);
float AngleRotate = AngleRotation * NewTime;
transform.Rotate(0, 0, AngleRotate);
TimePassed += NewTime;
DoorIsMoving = true;
transform.Rotate(0, 0, AngleRotation);
}
else {
DoorIsMoving = false;
CurrentAction = 0;
TimeRotation = 0;
TimePassed = 0.0f;
}
}
else if(CurrentAction == 2) {
if(TimeRotation < 900) {
TimeRotation += 1;
if(TimePassed < 1.0f) {
float NewTime = Mathf.Min(1.0f - TimePassed, Time.deltaTime);
float AngleRotate = -AngleRotation * NewTime;
transform.Rotate(0, 0, AngleRotate);
TimePassed += NewTime;
DoorIsMoving = true;
transform.Rotate(0, 0, -AngleRotation);
}
else {
DoorIsMoving = false;
CurrentAction = 0;
TimeRotation = 0;
TimePassed = 0.0f;
}
}
}

@ -89,7 +89,6 @@ public class Initalize : MonoBehaviour
void Op901() {
// Code to summon number from Input Bracket
Debug.Log(AllInput.Peek() + " and " + AllInput.Count);
AllOperation.Enqueue(Cope(100, AllInput.Peek(), 0));
FakeAccumulator = AllInput.Peek(); AllInput.Dequeue();
}
@ -143,6 +142,8 @@ public class Initalize : MonoBehaviour
int[] EncodeOperation = new int[100];
int InstructionLength = InstructionText.Length, Counter = 0;
for(int i = 0; i < InstructionLength - 2; i += 4) {
while(i < InstructionLength && !CheckDigit(InstructionText[i]))
++i;
EncodeOperation[Counter] = Convert.ToInt32(InstructionText.Substring(i, 3));
Counter += 1;
}
@ -199,7 +200,7 @@ public class Initalize : MonoBehaviour
if(ActionChange == 1) Door[IndexChange].OpenDoor();
else Door[IndexChange].CloseDoor();
}
if(Door[IndexChange].TimeRotation == 900) {
if(Door[IndexChange].TimePassed >= 1.0f) {
ActionExisted = false;
IndexChange = -1;
ActionChange = -1;
@ -237,4 +238,8 @@ public class Initalize : MonoBehaviour
}
}
}
void LateUpdate() {
}
}

@ -1324,7 +1324,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 17da3fd4e0129f5449ca3ef38c7c6467, type: 3}
propertyPath: m_LocalPosition.x
value: 60.667034
value: 66.8
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 17da3fd4e0129f5449ca3ef38c7c6467, type: 3}
propertyPath: m_LocalPosition.y
@ -4731,14 +4731,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 71.8, y: 49.9, z: -145.6}
m_LocalRotation: {x: 0.09587541, y: 0.24321201, z: -0.02416578, w: 0.9649207}
m_LocalPosition: {x: -12, y: 19.4, z: -38.9}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 11.349, y: 28.294, z: 0}
--- !u!1001 &966064722
PrefabInstance:
m_ObjectHideFlags: 0

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save