Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement