Finish Bobbing as an effect

This commit is contained in:
Sofia 2019-08-07 22:40:16 +03:00
parent a1950a7b7a
commit c28f71118f
2 changed files with 9 additions and 5 deletions

View File

@ -533,6 +533,8 @@ MonoBehaviour:
FurnitureExplosionFun: 4 FurnitureExplosionFun: 4
ShootingFunAmount: 0.2 ShootingFunAmount: 0.2
DebugAdd10Fun: 0 DebugAdd10Fun: 0
DebugSubtract10Fun: 0
GodMode: 0
--- !u!114 &5620918083888341557 --- !u!114 &5620918083888341557
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -546,8 +548,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
BobbedTransform: {fileID: 4562179207922364650} BobbedTransform: {fileID: 4562179207922364650}
BobbingGravity: 1.5 BobbingGravity: 0.8
BobbingLaunchSpeed: 0.25 BobbingLaunchSpeed: 0.1
BobbingDirection: {x: 0, y: 1} BobbingDirection: {x: 0, y: 1}
--- !u!1 &8489029732599905358 --- !u!1 &8489029732599905358
GameObject: GameObject:

View File

@ -6,6 +6,8 @@ public class Bobbing : MonoBehaviour {
public Transform BobbedTransform; public Transform BobbedTransform;
[Range(0, 1)]
public float BobbingMultiplier = 1;
public float BobbingGravity = 0.5f; public float BobbingGravity = 0.5f;
public float BobbingLaunchSpeed = 5f; public float BobbingLaunchSpeed = 5f;
public Vector2 BobbingDirection = new Vector2(0, 1); public Vector2 BobbingDirection = new Vector2(0, 1);
@ -15,13 +17,13 @@ public class Bobbing : MonoBehaviour {
private float CurrentBobbingState = 0; private float CurrentBobbingState = 0;
void Update() { void Update() {
BobbingSpeed -= BobbingGravity / 10 * Time.deltaTime; BobbingSpeed -= (BobbingGravity / 10 * Time.deltaTime);
if (CurrentBobbingState <= 0) { if (CurrentBobbingState <= 0) {
BobbingSpeed = BobbingLaunchSpeed / 10; BobbingSpeed = (BobbingLaunchSpeed / 10);
} }
CurrentBobbingState += BobbingSpeed; CurrentBobbingState += BobbingSpeed;
BobbedTransform.localPosition = BobbingDirection * CurrentBobbingState; BobbedTransform.localPosition = BobbingDirection * CurrentBobbingState * BobbingMultiplier;
} }
} }