Fix gun bobbing in hand

This commit is contained in:
Sofia 2019-08-14 21:35:06 +03:00
parent c31d32182b
commit 745e2fa1e4
2 changed files with 5 additions and 1 deletions

View File

@ -130,6 +130,7 @@ MonoBehaviour:
Sprite: {fileID: 4462327695001662280} Sprite: {fileID: 4462327695001662280}
BulletHole: {fileID: 427857587156450783} BulletHole: {fileID: 427857587156450783}
Cooldown: 0.2 Cooldown: 0.2
Bobbing: {fileID: 3522608540502111974}
--- !u!114 &3522608540502111974 --- !u!114 &3522608540502111974
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Saltosion.OneWeapon.Player; using Saltosion.OneWeapon.Player;
using Saltosion.OneWeapon.Effects;
namespace Saltosion.OneWeapon.Guns { namespace Saltosion.OneWeapon.Guns {
public class Gun : MonoBehaviour { public class Gun : MonoBehaviour {
@ -10,6 +11,7 @@ namespace Saltosion.OneWeapon.Guns {
public SpriteRenderer Sprite; public SpriteRenderer Sprite;
public Transform BulletHole; public Transform BulletHole;
public float Cooldown = 0.5f; public float Cooldown = 0.5f;
public Bobbing Bobbing;
private bool IsHeld = false; private bool IsHeld = false;
private float CurrCooldown = 0; private float CurrCooldown = 0;
@ -27,9 +29,10 @@ namespace Saltosion.OneWeapon.Guns {
PlayerController Player = collision.collider.GetComponent<PlayerController>(); PlayerController Player = collision.collider.GetComponent<PlayerController>();
if (Player != null) { if (Player != null) {
IsHeld = true; IsHeld = true;
Player.SetGun(this); Bobbing.BobbingMultiplier = 0;
Destroy(GetComponent<BoxCollider2D>()); Destroy(GetComponent<BoxCollider2D>());
Destroy(GetComponent<Rigidbody2D>()); Destroy(GetComponent<Rigidbody2D>());
Player.SetGun(this);
} }
} }