diff --git a/Assets/Prefabs/PushPullCube.prefab b/Assets/Prefabs/PushPullCube.prefab index c9d12ac..937a30a 100644 --- a/Assets/Prefabs/PushPullCube.prefab +++ b/Assets/Prefabs/PushPullCube.prefab @@ -30,7 +30,7 @@ Transform: m_GameObject: {fileID: 7120608647080996497} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 4.67, y: 0.76, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalScale: {x: 1.2, y: 1.2, z: 1.2} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 @@ -104,13 +104,13 @@ Rigidbody: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 7120608647080996497} serializedVersion: 2 - m_Mass: 70 + m_Mass: 80 m_Drag: 0 m_AngularDrag: 0.05 m_UseGravity: 1 m_IsKinematic: 0 m_Interpolate: 0 - m_Constraints: 120 + m_Constraints: 122 m_CollisionDetection: 0 --- !u!114 &7120608647080996507 MonoBehaviour: @@ -125,3 +125,5 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: objectType: 1 + detailSign: {fileID: 0} + MovePoints: [] diff --git a/Assets/Scenes/Testing/Filip.unity b/Assets/Scenes/Testing/Filip.unity index 6f7e26e..c47fe6e 100644 --- a/Assets/Scenes/Testing/Filip.unity +++ b/Assets/Scenes/Testing/Filip.unity @@ -591,31 +591,11 @@ PrefabInstance: propertyPath: m_Name value: PushPullCube objectReference: {fileID: 0} - - target: {fileID: 7120608647080996502, guid: 597897b562955934fae65d62e0a8e3cd, - type: 3} - propertyPath: m_Mass - value: 10000 - objectReference: {fileID: 0} - target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd, type: 3} propertyPath: m_RootOrder value: 6 objectReference: {fileID: 0} - - target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd, - type: 3} - propertyPath: m_LocalScale.x - value: 1.2 - objectReference: {fileID: 0} - - target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd, - type: 3} - propertyPath: m_LocalScale.y - value: 1.2 - objectReference: {fileID: 0} - - target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd, - type: 3} - propertyPath: m_LocalScale.z - value: 1.2 - objectReference: {fileID: 0} - target: {fileID: 7120608647080996506, guid: 597897b562955934fae65d62e0a8e3cd, type: 3} propertyPath: m_LocalPosition.x @@ -1619,7 +1599,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1663971021} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -3.51, y: 2.2, z: 0} + m_LocalPosition: {x: -3.51, y: 2.31, z: 0} m_LocalScale: {x: 2, y: 1.8, z: 2} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/Scripts/ObjectManager.cs b/Assets/Scripts/ObjectManager.cs index 1ddc366..77daf8f 100644 --- a/Assets/Scripts/ObjectManager.cs +++ b/Assets/Scripts/ObjectManager.cs @@ -118,6 +118,23 @@ public class ObjectManager : MonoBehaviour } } + private void OnTriggerStay(Collider other) + { + if (other.gameObject.tag == "Player") + { + if (objectType == ObjectType.Ladder) + { + playerManager = other.gameObject.GetComponent(); + if (playerManager.activeAbility.Count > 0 && playerManager.activeAbility[0] == 4) + { + playerManager.onLadder = true; + playerManager.GetComponent().useGravity = false; + interact = true; + } + } + } + } + private void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player") diff --git a/Assets/Scripts/PlayerManager.cs b/Assets/Scripts/PlayerManager.cs index 115a311..b4f974f 100644 --- a/Assets/Scripts/PlayerManager.cs +++ b/Assets/Scripts/PlayerManager.cs @@ -27,11 +27,13 @@ public class PlayerManager : MonoBehaviour public Image powerImage; private bool dubleJump = true; private GameObject pushPullObject; + private float pushPullObjectDistance; public float dashPower = 40f; public float dashTime = 0.2f; private float actualDashTime; private int dashButton; private bool dash = false; + private bool cannotMove = false; private bool startEating = false; @@ -67,6 +69,7 @@ public class PlayerManager : MonoBehaviour } if (actualHealth <= 0 || gameObject.transform.position.y < -400.0f) { + cannotMove = true; playerAnimator.Play("Die"); } if (interact) @@ -87,9 +90,11 @@ public class PlayerManager : MonoBehaviour } AbilityAction(); DeactivePowerCube(); - Move(); - RunSwitch(); - Animation(); + if (!cannotMove) { + Move(); + RunSwitch(); + Animation(); + } if (startEating) { @@ -107,7 +112,10 @@ public class PlayerManager : MonoBehaviour private void FixedUpdate() { - Jump(); + if (!cannotMove && !onLadder) + { + Jump(); + } } private void AbilityAction() @@ -116,10 +124,20 @@ public class PlayerManager : MonoBehaviour { if (pushPullObject != null) { - pushPullObject.GetComponent().MovePosition( - pushPullObject.transform.position + - (pushPullObject.transform.right * (run ? runSpeed : speed) * Input.GetAxis("Horizontal") * Time.deltaTime) - ); + float distance = Vector3.Distance(pushPullObject.transform.position, gameObject.transform.position); + if (pushPullObjectDistance - 0.1f <= distance && pushPullObjectDistance + 0.1f >= distance) + { + Rigidbody pcmRigidB = pushPullObject.GetComponent(); + pcmRigidB.constraints = RigidbodyConstraints.FreezeRotation; + pushPullObject.GetComponent().MovePosition( + pushPullObject.transform.position + + (pushPullObject.transform.right * (run ? runSpeed : speed) * Input.GetAxis("Horizontal") * Time.deltaTime) + ); + } + else + { + RemovePushPullObject(); + } } powerImage.sprite = powerIcons[1]; } @@ -185,13 +203,21 @@ public class PlayerManager : MonoBehaviour public void SetPushPullObject(GameObject objectPP) { if (activeAbility.Count > 0 && activeAbility[0] == 2) { + if (pushPullObject != null) + { + pushPullObject.GetComponent().constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionX; + } pushPullObject = objectPP; + pushPullObjectDistance = Vector3.Distance(pushPullObject.transform.position, gameObject.transform.position); } } public void RemovePushPullObject() { - pushPullObject = null; + if (pushPullObject != null) { + pushPullObject.GetComponent().constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionX; + pushPullObject = null; + } } void RunSwitch() @@ -326,16 +352,6 @@ public class PlayerManager : MonoBehaviour transform.localScale.y + savePower, transform.localScale.z + savePower ); - /*transform.localScale = new Vector3( - transform.localScale.x + power, - transform.localScale.y + power, - transform.localScale.z + power - );*/ - /*transform.localPosition = new Vector3( - transform.localPosition.x, - transform.localPosition.y + power * 2, - transform.localPosition.z - );*/ } else if (powerType == PowerCubeManager.PowerType.Faster) @@ -464,11 +480,13 @@ public class PlayerManager : MonoBehaviour public void StartEatPowerCube() { + cannotMove = true; startEating = true; } public void EndEatPowerCube() { + cannotMove = false; startEating = false; ActivePowerCube(powerCubeManager.powerUnit, powerCubeManager.powerTime, powerCubeManager.powerType, powerCubeManager.nextSceneName); Destroy(powerCubeManager.gameObject); diff --git a/Assets/Scripts/PowerCubeManager.cs b/Assets/Scripts/PowerCubeManager.cs index 22fe56b..2083b5d 100644 --- a/Assets/Scripts/PowerCubeManager.cs +++ b/Assets/Scripts/PowerCubeManager.cs @@ -58,6 +58,7 @@ public class PowerCubeManager : MonoBehaviour } } } + private void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player")