diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 25ee3d5..b7c5354 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -119,6 +119,73 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &67018399 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 67018400} + - component: {fileID: 67018402} + - component: {fileID: 67018401} + m_Layer: 0 + m_Name: StandUpCollider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &67018400 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 67018399} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 955231359} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &67018401 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 67018399} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 19aae932aa4446c4788d84deb1116128, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::StandUpCollider + ispushing: 0 +--- !u!135 &67018402 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 67018399} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Radius: 2 + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &209519236 GameObject: m_ObjectHideFlags: 0 @@ -1022,7 +1089,8 @@ Transform: m_LocalPosition: {x: -15.5, y: 1.23, z: 12.73} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 67018400} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &955231360 @@ -1040,7 +1108,9 @@ MonoBehaviour: basespeed: 8 speed: 8 speedincrease: 0.05 + maxspeed: 15 slide: 0.2 + standUp: {fileID: 0} --- !u!114 &955231361 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1118,6 +1188,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e7c1c3fec0605d746bddf36d1b260908, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::Pit + startmass: 0 --- !u!4 &1604116872 Transform: m_ObjectHideFlags: 0 @@ -1127,7 +1198,7 @@ Transform: m_GameObject: {fileID: 1604116870} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.3, y: -0.7, z: 13.1} + m_LocalPosition: {x: -2.3, y: -2.37, z: 13.1} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] diff --git a/Assets/Scripts/Pit.cs b/Assets/Scripts/Pit.cs index c4dc63b..5ee74a7 100644 --- a/Assets/Scripts/Pit.cs +++ b/Assets/Scripts/Pit.cs @@ -1,10 +1,16 @@ using System; using UnityEngine; +using UnityEngine.Serialization; public class Pit : MonoBehaviour { + public float startmass; private void OnTriggerEnter(Collider other) { + if (other.isTrigger) return; + startmass = other.GetComponent().mass; + other.GetComponent().mass = 100; + other.GetComponent().mass = startmass; other.GetComponent().Reset(); } } diff --git a/Assets/Scripts/Player/PlayerMove.cs b/Assets/Scripts/Player/PlayerMove.cs index ae765ac..2463c99 100644 --- a/Assets/Scripts/Player/PlayerMove.cs +++ b/Assets/Scripts/Player/PlayerMove.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using Unity.VisualScripting; using UnityEngine; public class PlayerMove : MonoBehaviour @@ -7,17 +8,22 @@ public class PlayerMove : MonoBehaviour [SerializeField] private float basespeed; [SerializeField] private float speed; [SerializeField] private float speedincrease; + [SerializeField] private float maxspeed; + private Rigidbody rb; [SerializeField] private float slide; Vector3 moveDirection; bool vertical; - bool horizontal; - + private bool horizontal; + + [SerializeField] private StandUpCollider standUp; + private void Start() { rb = GetComponent(); + standUp = FindAnyObjectByType(typeof(StandUpCollider)) as StandUpCollider; } void Update() @@ -31,12 +37,15 @@ public class PlayerMove : MonoBehaviour if (horizontalInput != 0 && horizontal == true) { - transform.rotation = Quaternion.Euler(0f, 0f, 90f); + if (!standUp.ispushing) + { + transform.rotation = Quaternion.Euler(0f, 0f, 90f); + } vertical = false; moveDirection = new Vector3(horizontalInput,0, 0); moveDirection.Normalize(); - if (!vertical) + if (!vertical && speed <= maxspeed && !standUp.ispushing) { speed += speedincrease; } @@ -44,12 +53,15 @@ public class PlayerMove : MonoBehaviour } else if (verticalInput != 0 && vertical == true) { - transform.rotation = Quaternion.Euler(90f, 0f, 0f); + if (!standUp.ispushing) + { + transform.rotation = Quaternion.Euler(90f, 0f, 0f); + } horizontal = false; moveDirection = new Vector3(0, 0, verticalInput); moveDirection.Normalize(); - if (!horizontal) + if (!horizontal && speed <= maxspeed && !standUp.ispushing) { speed += speedincrease; } @@ -77,4 +89,8 @@ public class PlayerMove : MonoBehaviour speed = basespeed; } + + + + } diff --git a/Assets/Scripts/Player/StandUpCollider.cs b/Assets/Scripts/Player/StandUpCollider.cs new file mode 100644 index 0000000..dbd0934 --- /dev/null +++ b/Assets/Scripts/Player/StandUpCollider.cs @@ -0,0 +1,24 @@ +using UnityEngine; + +public class StandUpCollider : MonoBehaviour +{ + public bool ispushing; + + private void OnTriggerEnter(Collider other) + { + IceBlockPush block = other.gameObject.GetComponent(); + if (block != null) + { + ispushing = true; + } + } + + private void OnTriggerExit(Collider other) + { + IceBlockPush block = other.gameObject.GetComponent(); + if (block != null) + { + ispushing = false; + } + } +} diff --git a/Assets/Scripts/Player/StandUpCollider.cs.meta b/Assets/Scripts/Player/StandUpCollider.cs.meta new file mode 100644 index 0000000..add4178 --- /dev/null +++ b/Assets/Scripts/Player/StandUpCollider.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 19aae932aa4446c4788d84deb1116128 \ No newline at end of file