diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 3bdfddf..25ee3d5 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -281,6 +281,7 @@ GameObject: - component: {fileID: 319279593} - component: {fileID: 319279592} - component: {fileID: 319279598} + - component: {fileID: 319279599} m_Layer: 0 m_Name: IceBlock m_TagString: IceBlock @@ -423,7 +424,7 @@ Transform: m_GameObject: {fileID: 319279591} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 9.4, y: 1.51404, z: 15.37} + m_LocalPosition: {x: -12.4, y: 1.51404, z: 15.37} m_LocalScale: {x: 2, y: 2, z: 2} m_ConstrainProportionsScale: 1 m_Children: [] @@ -442,7 +443,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Assembly-CSharp::IceBlockPush contactForce: 4 - StartPos: {x: 9.4, y: 1.51404, z: 15.37} +--- !u!114 &319279599 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 319279591} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8fc662358fbf8394d804207b2a8c9868, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::PositionReset + StartPos: {x: 9.2, y: 1.51404, z: 15.37} --- !u!1 &330585543 GameObject: m_ObjectHideFlags: 0 @@ -882,6 +895,7 @@ GameObject: - component: {fileID: 955231356} - component: {fileID: 955231355} - component: {fileID: 955231360} + - component: {fileID: 955231361} m_Layer: 0 m_Name: Penguin m_TagString: Untagged @@ -1026,8 +1040,20 @@ MonoBehaviour: basespeed: 8 speed: 8 speedincrease: 0.05 - StartPos: {x: -15.5, y: 1.23, z: 12.73} slide: 0.2 +--- !u!114 &955231361 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 955231353} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8fc662358fbf8394d804207b2a8c9868, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::PositionReset + StartPos: {x: -15.5, y: 1.23, z: 12.73} --- !u!1 &1262927943 GameObject: m_ObjectHideFlags: 0 @@ -1092,8 +1118,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e7c1c3fec0605d746bddf36d1b260908, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::Pit - player: {fileID: 955231360} - ice: {fileID: 319279598} --- !u!4 &1604116872 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/IceBlockPush.cs b/Assets/Scripts/IceBlockPush.cs index 8581b06..e364f41 100644 --- a/Assets/Scripts/IceBlockPush.cs +++ b/Assets/Scripts/IceBlockPush.cs @@ -5,7 +5,6 @@ public class IceBlockPush : MonoBehaviour { [SerializeField] float contactForce = 2.5f; private Rigidbody rb; - [SerializeField] private Vector3 StartPos; private void Start() { @@ -35,9 +34,4 @@ public class IceBlockPush : MonoBehaviour rb.AddForce(directionVector * contactForce, ForceMode.Impulse); } - - public void Reset() - { - this.transform.position = StartPos; - } } diff --git a/Assets/Scripts/Pit.cs b/Assets/Scripts/Pit.cs index af46bd7..c4dc63b 100644 --- a/Assets/Scripts/Pit.cs +++ b/Assets/Scripts/Pit.cs @@ -3,28 +3,8 @@ using UnityEngine; public class Pit : MonoBehaviour { - public PlayerMove player; - public IceBlockPush ice; - // - // // Update is called once per frame - // void Update() - // { - // if (Input.GetKeyDown(KeyCode.Space)) - // { - // player.Reset(); - // ice.Reset(); - // } - // } - private void OnTriggerEnter(Collider other) { - if (other.GetComponent()) - { - player.Reset(); - } - else if(other.GetComponent()) - { - ice.Reset(); - } + other.GetComponent().Reset(); } } diff --git a/Assets/Scripts/Player/PlayerMove.cs b/Assets/Scripts/Player/PlayerMove.cs index 09ac436..ae765ac 100644 --- a/Assets/Scripts/Player/PlayerMove.cs +++ b/Assets/Scripts/Player/PlayerMove.cs @@ -8,7 +8,6 @@ public class PlayerMove : MonoBehaviour [SerializeField] private float speed; [SerializeField] private float speedincrease; private Rigidbody rb; - [SerializeField] private Vector3 StartPos; [SerializeField] private float slide; Vector3 moveDirection; @@ -67,10 +66,7 @@ public class PlayerMove : MonoBehaviour transform.Translate(moveDirection * speed * Time.deltaTime, Space.World); } - public void Reset() - { - this.transform.position = StartPos; - } + IEnumerator Slide(float delay) { diff --git a/Assets/Scripts/PositionReset.cs b/Assets/Scripts/PositionReset.cs new file mode 100644 index 0000000..6257fd6 --- /dev/null +++ b/Assets/Scripts/PositionReset.cs @@ -0,0 +1,11 @@ +using UnityEngine; + +public class PositionReset : MonoBehaviour +{ + [SerializeField] private Vector3 StartPos; + + public void Reset() + { + this.transform.position = StartPos; + } +} diff --git a/Assets/Scripts/PositionReset.cs.meta b/Assets/Scripts/PositionReset.cs.meta new file mode 100644 index 0000000..2b8477c --- /dev/null +++ b/Assets/Scripts/PositionReset.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8fc662358fbf8394d804207b2a8c9868 \ No newline at end of file