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