Created
March 25, 2017 17:24
-
-
Save kubawich/06821c43db2c8b0594810d03453a216b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class ShootingHabit : MonoBehaviour { | |
public static ShootingHabit Instance; | |
bool hasWeapon; | |
public Animator animator; | |
public Transform HandPosition; | |
private void Awake() | |
{ | |
Instance = this; | |
animator = GetComponent<Animator>(); | |
hasWeapon = false; | |
} | |
private void Update() | |
{ | |
if (hasWeapon) | |
{ | |
animator.SetLayerWeight(1, 1); | |
} | |
} | |
void SetWeapon(GameObject weaponObject) | |
{ | |
Instantiate((Object)weaponObject, new Vector3(HandPosition.transform.position.x, HandPosition.transform.position.y, HandPosition.transform.position.z), Quaternion.identity); | |
} | |
private void OnTriggerEnter(Collider other) | |
{ | |
GameObject.Destroy(other.gameObject); | |
SetWeapon(other.gameObject); | |
hasWeapon = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment