Update AcceleratedMovement
This commit is contained in:
parent
6960cf93f2
commit
a2d1096764
@ -4,9 +4,9 @@ using UnityEngine;
|
|||||||
using Saltosion.OneWeapon.Effects;
|
using Saltosion.OneWeapon.Effects;
|
||||||
|
|
||||||
namespace Saltosion.OneWeapon.Utils {
|
namespace Saltosion.OneWeapon.Utils {
|
||||||
|
[RequireComponent(typeof(Rigidbody2D))]
|
||||||
public class AcceleratedMovement : MonoBehaviour {
|
public class AcceleratedMovement : MonoBehaviour {
|
||||||
|
|
||||||
public Rigidbody2D Body;
|
|
||||||
public Bobbing Bobbing;
|
public Bobbing Bobbing;
|
||||||
|
|
||||||
private Vector2 LastDirection = Vector2.zero;
|
private Vector2 LastDirection = Vector2.zero;
|
||||||
@ -19,6 +19,12 @@ namespace Saltosion.OneWeapon.Utils {
|
|||||||
public float SpeedPercentage { private set; get; }
|
public float SpeedPercentage { private set; get; }
|
||||||
private float CurrentSpeed = 0;
|
private float CurrentSpeed = 0;
|
||||||
|
|
||||||
|
private Rigidbody2D Body;
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
Body = GetComponent<Rigidbody2D>();
|
||||||
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
if (Direction.magnitude > 0) {
|
if (Direction.magnitude > 0) {
|
||||||
CurrentSpeed += AccelerationSpeed * Time.deltaTime;
|
CurrentSpeed += AccelerationSpeed * Time.deltaTime;
|
||||||
@ -33,7 +39,9 @@ namespace Saltosion.OneWeapon.Utils {
|
|||||||
|
|
||||||
LastDirection = Direction;
|
LastDirection = Direction;
|
||||||
Body.velocity = CurrentVelocity;
|
Body.velocity = CurrentVelocity;
|
||||||
Bobbing.BobbingMultiplier = SpeedPercentage;
|
if (Bobbing != null) {
|
||||||
|
Bobbing.BobbingMultiplier = SpeedPercentage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user