Skip to content
Snippets Groups Projects

Feature physics

Merged Clinton Galbraith requested to merge feature_physics into develop
21 files
+ 1003
229
Compare changes
  • Side-by-side
  • Inline
Files
21
@@ -6,14 +6,16 @@ public class PlayerBehavior : MonoBehaviour {
/* Movement to apply this frame */
private Vector3 frameMovement;
/* How much force is applied by player movement */
[SerializeField]
private float acceleration;
/* How much the velocity is scaled down on brake */
[SerializeField]
private float brakeFraction;
[SerializeField]
private float constantFraction;
/* The maximum speed a player is allowed to go */
[SerializeField]
@@ -24,6 +26,12 @@ public class PlayerBehavior : MonoBehaviour {
private Rigidbody2D playerBody;
/* Getters and Setters */
public float getMaxSpeed()
{
return maxSpeed;
}
/**
* Collection of basic movement functions that add to a movement vector, which is
* reset every frame.
@@ -72,7 +80,7 @@ public class PlayerBehavior : MonoBehaviour {
playerBody.velocity = (playerBody.velocity.normalized * maxSpeed);
/* Apply some simple friction */
playerBody.velocity *= .99f;
playerBody.velocity *= constantFraction;
/* Reset any persistant variables */
frameMovement = Vector3.zero;
Loading