Make player control the bobbing properly

This commit is contained in:
Sofia 2019-08-07 22:43:22 +03:00
parent c28f71118f
commit 4898d2c435
3 changed files with 27 additions and 18 deletions

View File

@ -512,6 +512,7 @@ MonoBehaviour:
PlayerFun: {fileID: 5050980832709922958}
HandRetractSpeed: 10
HandRotationRetractSpeed: 300
Bobbing: {fileID: 5620918083888341557}
--- !u!114 &5050980832709922958
MonoBehaviour:
m_ObjectHideFlags: 0
@ -548,6 +549,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
BobbedTransform: {fileID: 4562179207922364650}
BobbingMultiplier: 1
BobbingGravity: 0.8
BobbingLaunchSpeed: 0.1
BobbingDirection: {x: 0, y: 1}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
namespace Saltosion.OneWeapon.Effects {
public class Bobbing : MonoBehaviour {
public Transform BobbedTransform;
@ -27,3 +28,4 @@ public class Bobbing : MonoBehaviour {
}
}
}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
using Saltosion.OneWeapon.Effects;
namespace Saltosion.OneWeapon {
public class Player : MonoBehaviour {
@ -36,6 +37,8 @@ namespace Saltosion.OneWeapon {
private float CurrentHandRotation = 0f;
private float CurrentHandDistance = 0f;
public Bobbing Bobbing;
public bool IsMoving {
private set; get;
} = false;
@ -96,10 +99,12 @@ namespace Saltosion.OneWeapon {
BodyAnim.SetFloat("Speed", 1);
HeadAnim.SetFloat("Speed", 1);
IsMoving = true;
Bobbing.BobbingMultiplier = 1;
} else {
BodyAnim.SetFloat("Speed", 0);
HeadAnim.SetFloat("Speed", 0);
IsMoving = false;
Bobbing.BobbingMultiplier = 0;
}
bool Shoot = Input.GetButtonDown("Shoot");