Advertisement
Archania

Casting Spells

Jul 21st, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Casting : MonoBehaviour
  5. {
  6. private Animator animator;
  7. private CharacterController controller;
  8. private Transform xSpell;
  9.  
  10. public Transform spells;
  11. public Transform spell1;
  12. public Transform spell2;
  13. public Transform spell3;
  14. public Transform spell4;
  15. public Transform spell5;
  16. public Transform spell6;
  17. public Transform spell7;
  18. public Transform spell8;
  19.  
  20. // Use this for initialization
  21. void Start ()
  22. {
  23. controller = GetComponent<CharacterController>();
  24. animator = GetComponent<Animator>();
  25. }
  26.  
  27. void Update()
  28. {
  29. if (controller.isGrounded)
  30. {
  31. if (Input.GetKeyDown("1"))
  32. {
  33. animator.SetBool("CastFireball", true);
  34. xSpell = spell1;
  35. }
  36. else
  37. {
  38. animator.SetBool("CastFireball", false);
  39. }
  40.  
  41. if (Input.GetKeyDown("2"))
  42. {
  43. animator.SetBool("CastFireball", true);
  44. xSpell = spell2;
  45. }
  46. else
  47. {
  48. animator.SetBool("CastFireball", false);
  49. }
  50.  
  51. /* if (Input.GetKeyDown("3"))
  52. {
  53. animator.SetBool("CastFireball", true);
  54. xSpell = spell3;
  55. }
  56. else
  57. {
  58. animator.SetBool("CastFireball", false);
  59. }
  60.  
  61. if (Input.GetKeyDown("4"))
  62. {
  63. animator.SetBool("CastFireball", true);
  64. xSpell = spell4;
  65. }
  66. else
  67. {
  68. animator.SetBool("CastFireball", false);
  69. }
  70.  
  71. if (Input.GetKeyDown("5"))
  72. {
  73. animator.SetBool("CastFireball", true);
  74. xSpell = spell5;
  75. }
  76. else
  77. {
  78. animator.SetBool("CastFireball", false);
  79. }
  80.  
  81. if (Input.GetKeyDown("6"))
  82. {
  83. animator.SetBool("CastFireball", true);
  84. xSpell = spell6;
  85. }
  86. else
  87. {
  88. animator.SetBool("CastFireball", false);
  89. }
  90.  
  91. if (Input.GetKeyDown("7"))
  92. {
  93. animator.SetBool("CastFireball", true);
  94. xSpell = spell7;
  95. }
  96. else
  97. {
  98. animator.SetBool("CastFireball", false);
  99. }
  100.  
  101. if (Input.GetKeyDown("8"))
  102. {
  103. animator.SetBool("CastFireball", true);
  104. xSpell = spell8;
  105. }
  106. else
  107. {
  108. animator.SetBool("CastFireball", false);
  109. }
  110. */
  111. }
  112. }
  113.  
  114. void SpellCast ()
  115. {
  116. Instantiate (xSpell, spells.position, spells.rotation);
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement