Cleaned up jumping and double jumping implementation
This commit is contained in:
@@ -96,6 +96,7 @@ LightmapSettings:
|
|||||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||||
m_ExportTrainingData: 0
|
m_ExportTrainingData: 0
|
||||||
m_TrainingDataDestination: TrainingData
|
m_TrainingDataDestination: TrainingData
|
||||||
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
m_LightingDataAsset: {fileID: 0}
|
m_LightingDataAsset: {fileID: 0}
|
||||||
m_UseShadowmask: 1
|
m_UseShadowmask: 1
|
||||||
--- !u!196 &4
|
--- !u!196 &4
|
||||||
@@ -199,6 +200,7 @@ MeshRenderer:
|
|||||||
m_MotionVectors: 1
|
m_MotionVectors: 1
|
||||||
m_LightProbeUsage: 1
|
m_LightProbeUsage: 1
|
||||||
m_ReflectionProbeUsage: 1
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
@@ -270,8 +272,9 @@ Light:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 705507993}
|
m_GameObject: {fileID: 705507993}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 9
|
serializedVersion: 10
|
||||||
m_Type: 1
|
m_Type: 1
|
||||||
|
m_Shape: 0
|
||||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||||
m_Intensity: 1
|
m_Intensity: 1
|
||||||
m_Range: 10
|
m_Range: 10
|
||||||
@@ -396,6 +399,7 @@ MeshRenderer:
|
|||||||
m_MotionVectors: 1
|
m_MotionVectors: 1
|
||||||
m_LightProbeUsage: 1
|
m_LightProbeUsage: 1
|
||||||
m_ReflectionProbeUsage: 1
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
@@ -477,6 +481,7 @@ MeshRenderer:
|
|||||||
m_MotionVectors: 1
|
m_MotionVectors: 1
|
||||||
m_LightProbeUsage: 1
|
m_LightProbeUsage: 1
|
||||||
m_ReflectionProbeUsage: 1
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
@@ -537,7 +542,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
speed: 20
|
speed: 20
|
||||||
jumpSpeed: 20
|
jumpHeight: 15
|
||||||
gravity: 5
|
gravity: 5
|
||||||
rotationSpeed: 20
|
rotationSpeed: 20
|
||||||
pivot: {fileID: 1402695046}
|
pivot: {fileID: 1402695046}
|
||||||
@@ -620,6 +625,7 @@ MeshRenderer:
|
|||||||
m_MotionVectors: 1
|
m_MotionVectors: 1
|
||||||
m_LightProbeUsage: 1
|
m_LightProbeUsage: 1
|
||||||
m_ReflectionProbeUsage: 1
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ public class PlayerController : MonoBehaviour
|
|||||||
CharacterController characterController;
|
CharacterController characterController;
|
||||||
|
|
||||||
public float speed;
|
public float speed;
|
||||||
public float jumpSpeed;
|
public float jumpHeight;
|
||||||
public float gravity;
|
public float gravity;
|
||||||
public float rotationSpeed;
|
public float rotationSpeed;
|
||||||
public Transform pivot;
|
public Transform pivot;
|
||||||
public GameObject playerModel;
|
public GameObject playerModel;
|
||||||
|
|
||||||
private bool extraJump = true;
|
private int jump = 0;
|
||||||
private Vector3 moveDirection;
|
private Vector3 moveDirection;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
@@ -33,7 +33,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
//Need to switch to 'raw' when using keyboard
|
//Need to switch to 'raw' when using keyboard
|
||||||
moveDirection = (transform.forward * Input.GetAxis("Vertical")) + (transform.right * Input.GetAxis("Horizontal"));
|
moveDirection = (transform.forward * Input.GetAxis("Vertical")) + (transform.right * Input.GetAxis("Horizontal"));
|
||||||
|
|
||||||
if (extraJump == true)
|
if (jump <= 1)
|
||||||
{
|
{
|
||||||
moveDirection = moveDirection.normalized * speed; //Remove this line to make running diagonal the fastest standard run
|
moveDirection = moveDirection.normalized * speed; //Remove this line to make running diagonal the fastest standard run
|
||||||
} else
|
} else
|
||||||
@@ -45,7 +45,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
|
|
||||||
if (characterController.isGrounded)
|
if (characterController.isGrounded)
|
||||||
{
|
{
|
||||||
extraJump = true;
|
jump = 0;
|
||||||
moveDirection.y = 0.0f;
|
moveDirection.y = 0.0f;
|
||||||
|
|
||||||
if(Input.GetKey(KeyCode.LeftShift))
|
if(Input.GetKey(KeyCode.LeftShift))
|
||||||
@@ -55,21 +55,15 @@ public class PlayerController : MonoBehaviour
|
|||||||
moveDirection = moveDirection.normalized * speed;
|
moveDirection = moveDirection.normalized * speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetButtonDown("Jump"))
|
}
|
||||||
{
|
|
||||||
moveDirection.y = jumpSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (Input.GetButtonDown("Jump") && extraJump == true)
|
|
||||||
{
|
|
||||||
moveDirection.y = jumpSpeed;
|
|
||||||
extraJump = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (Input.GetButtonDown("Jump") && jump <= 1)
|
||||||
|
{
|
||||||
|
moveDirection.y = jumpHeight;
|
||||||
|
jump++;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveDirection.y = moveDirection.y + (Physics.gravity.y * gravity * Time.deltaTime);
|
moveDirection.y += Physics.gravity.y * gravity * Time.deltaTime;
|
||||||
|
|
||||||
// Move the controller
|
// Move the controller
|
||||||
characterController.Move(moveDirection * Time.deltaTime);
|
characterController.Move(moveDirection * Time.deltaTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user