adding isGrounded property

master
Jordan Orelli 4 years ago
parent a3dacc27f8
commit a5b663c838

@ -623,18 +623,8 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4623847142764859891, guid: b29a944aaba25f643afdc6b049845662, - target: {fileID: 4623847142764859891, guid: b29a944aaba25f643afdc6b049845662,
type: 3} type: 3}
propertyPath: timeToJumpApex propertyPath: timeToMaxRunSpeed
value: 0.97 value: 0.15
objectReference: {fileID: 0}
- target: {fileID: 4623847142764859891, guid: b29a944aaba25f643afdc6b049845662,
type: 3}
propertyPath: maxFallSpeed
value: -20
objectReference: {fileID: 0}
- target: {fileID: 4623847142764859892, guid: b29a944aaba25f643afdc6b049845662,
type: 3}
propertyPath: collisionMask.m_Bits
value: 1024
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b29a944aaba25f643afdc6b049845662, type: 3} m_SourcePrefab: {fileID: 100100000, guid: b29a944aaba25f643afdc6b049845662, type: 3}

@ -19,6 +19,10 @@ public class MoveController : MonoBehaviour
new BoxCollider2D collider; new BoxCollider2D collider;
RaycastOrigins raycastOrigins; RaycastOrigins raycastOrigins;
public bool isGrounded {
get => collisions.below;
}
void Start() { void Start() {
collider = GetComponent<BoxCollider2D>(); collider = GetComponent<BoxCollider2D>();
CalculateRaySpacing(); CalculateRaySpacing();

@ -38,7 +38,7 @@ public class PlayerController : MonoBehaviour {
} }
float targetX = input.x * moveSpeed; float targetX = input.x * moveSpeed;
if (moveController.collisions.below) { if (moveController.isGrounded) {
velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxRunSpeed); velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxRunSpeed);
} else { } else {
velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxAirmoveSpeed); velocity.x = Mathf.SmoothDamp(velocity.x, targetX, ref velocityXSmoothing, timeToMaxAirmoveSpeed);

Loading…
Cancel
Save