From 917119d319d4a02b07d8848a205bae60748c84fa Mon Sep 17 00:00:00 2001 From: James Hodgson Date: Mon, 11 Apr 2022 19:02:46 +0100 Subject: [PATCH] Make jump speed a public variable --- Assets/Scenes/SampleScene.unity | 2 +- Assets/Scripts/FishController.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index fa87970..664f0cc 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -840,7 +840,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 184b34bca7785c52e81be409a778c622, type: 3} m_Name: m_EditorClassIdentifier: - speed: 4 + speed: 5 gravity: -9.81 velocity: {x: 0, y: 0, z: 0} drag: {x: 0.1, y: 0.1, z: 0.1} diff --git a/Assets/Scripts/FishController.cs b/Assets/Scripts/FishController.cs index f86f824..451bc8d 100644 --- a/Assets/Scripts/FishController.cs +++ b/Assets/Scripts/FishController.cs @@ -7,6 +7,7 @@ public class FishController : MonoBehaviour { public float speed = 4f; public float gravity = -9.81f; + public float jumpSpeed = 8; public Vector3 velocity; public Vector3 drag; @@ -32,7 +33,7 @@ public class FishController : MonoBehaviour if (Input.GetButtonDown("Jump") && controller.isGrounded) { - velocity.y += 8; + velocity.y += jumpSpeed; } velocity.x = moveX * speed; @@ -43,7 +44,6 @@ public class FishController : MonoBehaviour if (moveVelocity.y < 0 && Math.Abs(moveVelocity.y) < controller.minMoveDistance) { - Debug.Log(String.Format("Abs velocity: {0}, controller.minMoveDistance: {1}", Math.Abs(moveVelocity.y), controller.minMoveDistance)); moveVelocity.y = (gravity * 0.1f) * Time.deltaTime; }