Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ShootingHabit : MonoBehaviour {
  6. public static ShootingHabit Instance;
  7. bool hasWeapon;
  8. public Animator animator;
  9. public Transform HandPosition;
  10.  
  11. private void Awake()
  12. {
  13. Instance = this;
  14. animator = GetComponent<Animator>();
  15. hasWeapon = false;
  16. }
  17. private void Update()
  18. {
  19. if (hasWeapon)
  20. {
  21. animator.SetLayerWeight(1, 1);
  22. }
  23. }
  24.  
  25. void SetWeapon(GameObject weaponObject)
  26. {
  27. Instantiate((Object)weaponObject, new Vector3(HandPosition.transform.position.x, HandPosition.transform.position.y, HandPosition.transform.position.z), Quaternion.identity);
  28. }
  29.  
  30. private void OnTriggerEnter(Collider other)
  31. {
  32. GameObject.Destroy(other.gameObject);
  33. SetWeapon(other.gameObject);
  34. hasWeapon = true;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement