BloodAndGore/Assets/Scripts/Effects/Bobbing.cs
2019-08-07 22:25:39 +03:00

28 lines
698 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bobbing : MonoBehaviour {
public Transform BobbedTransform;
public float BobbingGravity = 0.5f;
public float BobbingLaunchSpeed = 5f;
public Vector2 BobbingDirection = new Vector2(0, 1);
private float BobbingSpeed;
private float CurrentBobbingState = 0;
void Update() {
BobbingSpeed -= BobbingGravity / 10 * Time.deltaTime;
if (CurrentBobbingState <= 0) {
BobbingSpeed = BobbingLaunchSpeed / 10;
}
CurrentBobbingState += BobbingSpeed;
BobbedTransform.localPosition = BobbingDirection * CurrentBobbingState;
}
}