From dfe4d047e91405069c7e1df3b83fdb057be8791f Mon Sep 17 00:00:00 2001 From: Glence Date: Sat, 18 Feb 2023 22:21:23 +0800 Subject: [PATCH] added a jumppad to the game --- Assets/Scenes/MainGame.shade | 37 ++++++++++++++++--- .../Gameplay/Player/SC_PlayerController.cs | 14 ++++++- Assets/Scripts/SC_JumpPad.cs | 22 +++++++++++ Assets/Scripts/SC_JumpPad.cs.shmeta | 3 ++ 4 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 Assets/Scripts/SC_JumpPad.cs create mode 100644 Assets/Scripts/SC_JumpPad.cs.shmeta diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index 87343839..53b5a0a0 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -9671,6 +9671,7 @@ maxJumpHeight: 2 maxJumpTime: 0.75 fallMultipler: 3 + jumpPadMultiplayer: 1.20000005 lightMultiper: 0.75 mediumMultiper: 0.5 heavyMultiper: 0.25 @@ -9682,6 +9683,7 @@ aimingLength: 1 throwItem: false rayDistance: 0.75 + rayHeight: 0.100000001 - EID: 3 Name: HoldingPoint IsActive: true @@ -10483,11 +10485,11 @@ Translate: {x: 2.70000005, y: 0.100000001, z: -2} Rotate: {x: -0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} - IsActive: true + IsActive: false Renderable Component: Mesh: 140697366 Material: 129495479 - IsActive: true + IsActive: false RigidBody Component: Type: Dynamic Drag: 0.00999999978 @@ -10501,7 +10503,7 @@ Freeze Rotation X: true Freeze Rotation Y: false Freeze Rotation Z: true - IsActive: true + IsActive: false Collider Component: Colliders: - Is Trigger: false @@ -10513,7 +10515,7 @@ Density: 1 Position Offset: {x: 0, y: 0.899999976, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} - IsActive: true + IsActive: false Scripts: - Type: Homeowner1 Enabled: true @@ -10525,4 +10527,29 @@ eyeOffset: [0, 1.64999998, 0] distanceToCapture: 0.5 captureTime: 0.5 - footstepSFXIntervalMultiplier: 0.5 \ No newline at end of file + footstepSFXIntervalMultiplier: 0.5 +- EID: 16 + Name: Default + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 3.43332767, y: 0.149463654, z: 6.84711409} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Collider Component: + Colliders: + - Is Trigger: false + Collision Tag: 0 + Type: Box + Half Extents: {x: 1, y: 0.25, z: 1} + Friction: 0.400000006 + Bounciness: 0 + Density: 1 + Position Offset: {x: 0, y: 0, z: 0} + Rotation Offset: {x: 0, y: 0, z: 0} + IsActive: true + Scripts: + - Type: JumpPad + Enabled: true \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs index d66e7e30..202e587e 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -65,7 +65,7 @@ public class PlayerController : Script //Jumping vars================================================================== [Tooltip("max height of the jump")] public float maxJumpHeight = 1.0f; - [Tooltip("max amt of time it will take for the jump")] + [Tooltip("max amount of time it will take for the jump")] public float maxJumpTime = 0.5f; [Tooltip("increase gravity when falling")] public float fallMultipler = 3.0f; @@ -73,6 +73,9 @@ public class PlayerController : Script private bool isGrounded = true; private float gravity = -9.8f; private float groundGravity = -0.5f; + public bool landedOnJumpPad { get; set; } + [Tooltip("multiply height on Jump Pad ")] + public float jumpPadMultiplayer = 2.0f; //ItemMultipler================================================================== [Tooltip("How light item will affect player jump")] @@ -88,6 +91,7 @@ public class PlayerController : Script isMoveKeyPress = false; holdItem = false; isAiming = false; + landedOnJumpPad = false; //Jump setup float timeToApex = maxJumpTime / 2; @@ -287,7 +291,7 @@ public class PlayerController : Script { if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE) { - if (Input.GetKeyDown(Input.KeyCode.Space) && isGrounded && rb != null) + if ( (Input.GetKeyDown(Input.KeyCode.Space) || landedOnJumpPad ) && isGrounded && rb != null) { currentState = RaccoonStates.JUMP; Vector3 v = rb.LinearVelocity; @@ -302,6 +306,12 @@ public class PlayerController : Script if (item != null && item.currCategory == ItemCategory.HEAVY) v.y *= heavyMultiper; } + + if (landedOnJumpPad) + { + v.y *= jumpPadMultiplayer; + landedOnJumpPad = false; + } rb.LinearVelocity = v; } } diff --git a/Assets/Scripts/SC_JumpPad.cs b/Assets/Scripts/SC_JumpPad.cs new file mode 100644 index 00000000..0e331f8c --- /dev/null +++ b/Assets/Scripts/SC_JumpPad.cs @@ -0,0 +1,22 @@ +using SHADE; +using System; + +public class JumpPad : Script +{ + protected override void awake() + { + } + + protected override void update() + { + } + + protected override void onCollisionEnter(CollisionInfo info) + { + if (info.GameObject.GetScript() && info.GameObject.GetScript().currentState == PlayerController.RaccoonStates.FALLING) + { + info.GameObject.GetScript().landedOnJumpPad = true; + } + } + +} diff --git a/Assets/Scripts/SC_JumpPad.cs.shmeta b/Assets/Scripts/SC_JumpPad.cs.shmeta new file mode 100644 index 00000000..62a99f19 --- /dev/null +++ b/Assets/Scripts/SC_JumpPad.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_JumpPad +ID: 167326885 +Type: 9