fix: player now jumps normally
This commit is contained in:
@@ -66,6 +66,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: f16350ecb17bc8e49a8e9b8124ff2db2, type: 3}
|
m_Script: {fileID: 11500000, guid: f16350ecb17bc8e49a8e9b8124ff2db2, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
groundMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 64
|
||||||
--- !u!1 &1084592339258698369
|
--- !u!1 &1084592339258698369
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -247,6 +250,7 @@ GameObject:
|
|||||||
- component: {fileID: 1892283461227420150}
|
- component: {fileID: 1892283461227420150}
|
||||||
- component: {fileID: 7857072580326449292}
|
- component: {fileID: 7857072580326449292}
|
||||||
- component: {fileID: 1437407097293080706}
|
- component: {fileID: 1437407097293080706}
|
||||||
|
- component: {fileID: 8985924327125149956}
|
||||||
- component: {fileID: 397169322893853401}
|
- component: {fileID: 397169322893853401}
|
||||||
- component: {fileID: 1198108720433238150}
|
- component: {fileID: 1198108720433238150}
|
||||||
- component: {fileID: 3263211181679880648}
|
- component: {fileID: 3263211181679880648}
|
||||||
@@ -353,6 +357,33 @@ CharacterController:
|
|||||||
m_SkinWidth: 0.08
|
m_SkinWidth: 0.08
|
||||||
m_MinMoveDistance: 0.001
|
m_MinMoveDistance: 0.001
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!54 &8985924327125149956
|
||||||
|
Rigidbody:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 9016311960615966999}
|
||||||
|
serializedVersion: 4
|
||||||
|
m_Mass: 1
|
||||||
|
m_Drag: 0
|
||||||
|
m_AngularDrag: 0.05
|
||||||
|
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||||
|
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||||
|
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ImplicitCom: 1
|
||||||
|
m_ImplicitTensor: 1
|
||||||
|
m_UseGravity: 0
|
||||||
|
m_IsKinematic: 0
|
||||||
|
m_Interpolate: 0
|
||||||
|
m_Constraints: 80
|
||||||
|
m_CollisionDetection: 0
|
||||||
--- !u!114 &397169322893853401
|
--- !u!114 &397169322893853401
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -371,11 +402,6 @@ MonoBehaviour:
|
|||||||
crouchHeightMultiplier: 0.5
|
crouchHeightMultiplier: 0.5
|
||||||
jumpForce: 10
|
jumpForce: 10
|
||||||
gravityMultiplier: 1
|
gravityMultiplier: 1
|
||||||
legsPosition: {fileID: 2033391409425088012}
|
|
||||||
legsRadius: 0.2
|
|
||||||
groundMask:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 64
|
|
||||||
isCrouching: 0
|
isCrouching: 0
|
||||||
gravityVelocity: {x: 0, y: 0, z: 0}
|
gravityVelocity: {x: 0, y: 0, z: 0}
|
||||||
grounded: 0
|
grounded: 0
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class GroundDetector : MonoBehaviour
|
public class GroundDetector : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public LayerMask groundMask;
|
||||||
public bool onGround { get; private set; } = false;
|
public bool onGround { get; private set; } = false;
|
||||||
|
|
||||||
void OnTriggerEnter(Collider other) {
|
public void OnTriggerEnter(Collider other) {
|
||||||
if (other.CompareTag("Ground")) onGround = true;
|
if ((1 << other.gameObject.layer & groundMask) != 0) onGround = true;
|
||||||
}
|
}
|
||||||
void OnTriggerStay(Collider other) { OnTriggerEnter(other); }
|
void OnTriggerStay(Collider other) { OnTriggerEnter(other); }
|
||||||
void OnTriggerExit(Collider other) {
|
void OnTriggerExit(Collider other) {
|
||||||
if (other.CompareTag("Ground")) onGround = false;
|
if ((1 << other.gameObject.layer & groundMask) != 0) onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
[Header("Vertical movement")]
|
[Header("Vertical movement")]
|
||||||
public float jumpForce = 1f;
|
public float jumpForce = 1f;
|
||||||
public float gravityMultiplier = 1f;
|
public float gravityMultiplier = 1f;
|
||||||
public Transform legsPosition;
|
|
||||||
public float legsRadius = 0.5f;
|
|
||||||
public LayerMask groundMask;
|
|
||||||
|
|
||||||
[Header("Debug info")]
|
[Header("Debug info")]
|
||||||
[SerializeField] bool isCrouching = false;
|
[SerializeField] bool isCrouching = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user