Update AcceleratedMovement

This commit is contained in:
Sofia 2019-08-18 20:51:03 +03:00
parent 6960cf93f2
commit a2d1096764

View File

@ -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;
}
}
}
}