Bullet.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Bullet : PhysicalObject
  5. {
  6. public string ammoType; // ammo type
  7. public bool armed=true; // if ammo ready to shoot
  8. public Mesh shellModel; // object of casing , which will be replaced after shot
  9. void Start()
  10. {
  11. Initialize ();
  12. }
  13. new void GrabStart(CustomHand hand)
  14. {
  15. GrabStartCustom(hand);
  16. }
  17. new public void GrabUpdate(CustomHand hand){
  18. GrabUpdateCustom (hand);
  19. }
  20. new public void GrabEnd(CustomHand hand){
  21. GrabEndCustom(hand);
  22. }
  23. public void ChangeModel(){
  24. MeshFilter myMeshfilter = GetComponentInChildren<MeshFilter>();
  25. myMeshfilter.mesh = shellModel;
  26. armed = false;
  27. }
  28. public void DettachBullet(){
  29. DettachHands ();
  30. saveVariables.LoadProperty (MyRigidbody);
  31. }
  32. public void EnterMagazine(){
  33. Collider[] tempCollider= GetComponentsInChildren<Collider> ();
  34. for (int i = 0; i < tempCollider.Length; i++) {
  35. tempCollider [i].enabled = false;
  36. }
  37. MyRigidbody.isKinematic = true;
  38. }
  39. public void OutMagazine(){
  40. Collider[] tempCollider= GetComponentsInChildren<Collider> ();
  41. for (int i = 0; i < tempCollider.Length; i++) {
  42. tempCollider [i].enabled = true;
  43. }
  44. MyRigidbody.isKinematic = false;
  45. }
  46. }