adding isGrounded property

master
Jordan Orelli 4 years ago
parent a3dacc27f8
commit a5b663c838

@ -623,18 +623,8 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4623847142764859891, guid: b29a944aaba25f643afdc6b049845662,
type: 3}
propertyPath: timeToJumpApex
value: 0.97
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
propertyPath: timeToMaxRunSpeed
value: 0.15
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b29a944aaba25f643afdc6b049845662, type: 3}

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

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

Loading…
Cancel
Save