Advertisement
Ramaraunt1

Untitled

Dec 20th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class characterController : MonoBehaviour {
  5.  
  6. /*/////////////////////////////////////////////////
  7. * DECLARATIONS
  8. *///////////////////////////////////////////////////
  9.  
  10. //CAMERAS BEGIN
  11. //camera storage variables
  12. public Camera firstPersonCamera;
  13. public Camera thirdPersonCamera;
  14. private bool firstPerson = true;
  15. private bool thirdPerson = false;
  16.  
  17. //camera_movement_speed
  18. public float speed = 5.0f;
  19. //CAMERAS END
  20.  
  21. //ANIMATION/MOVEMENT BEGIN
  22. //animation controller
  23. public Animator animationController;
  24.  
  25. //animation modes
  26. /*
  27. *0 = unalert
  28. *1 = combat stance
  29. *2 = sneaking stance
  30. *3 = wounded
  31. */
  32. public float animation_mode = 0;
  33.  
  34. //animation states
  35. /*
  36. * 0 = still
  37. * 1 = moving slow/walking
  38. * 2 = moving fast/running/jogging
  39. */
  40. public float animation_state = 0;
  41.  
  42. //swing_state
  43. /* THIS USES A COMPASS SYSTEM. Up is north, west is left, down is south, east is right.
  44. * -4 = noone
  45. * -3 = unsheathe
  46. * -2 = sheathe
  47. * -1 = taunt
  48. * 0 = north hold
  49. * 1 = north release
  50. * 2 = northeast hold
  51. * 3 = northeast release
  52. * 4 = east hold
  53. * 5 = east release
  54. * 6 = southeast hold
  55. * 7 = southeast release
  56. * 8 = south hold
  57. * 9 = south release
  58. * 10 = southwest hold
  59. * 11 = southwest release
  60. * 12 = west hold
  61. * 13 = west release
  62. * 14 = norhtwest hold
  63. * 15 = northwest release
  64. * 16 = north block
  65. * 17 = east block
  66. * 18 = south block
  67. * 19 = west block
  68. * 20 = shield block
  69. * 21 = throw pull
  70. * 22 = throw release
  71. * 23 = arrow draw
  72. * 24 = arrow release
  73. * 25 = arrow return
  74. * 26 = xbow reload crank
  75. * 27 = xbow reload pull
  76. * 28 = xbow aim
  77. * 29 = xbow fire
  78. * 30 = take damage
  79. */
  80. public int swing_state = -4;
  81.  
  82. //weapon_kind
  83. /* Type of weapon currently equiped, used for animations.
  84. * 0 = none (fists)
  85. * 1 = onehanded
  86. * 2 = twohanded
  87. * 3 = polearm
  88. * 4 = throwing
  89. * 5 = bow
  90. * 6 = xbow
  91. */
  92. public int weapon_kind = 0;
  93. //ANIMATION/MOVEMENT END
  94.  
  95.  
  96.  
  97. /*/////////////////////////////////////////////////
  98. * ACTION METHODS
  99. *///////////////////////////////////////////////////
  100.  
  101. //
  102. // Use this for initialization
  103. void Start () {
  104. //set cursor as locked
  105. Cursor.lockState = CursorLockMode.Locked;
  106. }
  107.  
  108.  
  109.  
  110. // Update is called once per frame
  111. void Update () {
  112.  
  113. //CAMERA STUFF BEGIN
  114. float translation = Input.GetAxis("Vertical") * speed;
  115. float straffe = Input.GetAxis("Horizontal") * speed;
  116. translation *= Time.deltaTime;
  117. straffe *= Time.deltaTime;
  118.  
  119. transform.Translate(straffe, 0, translation);
  120.  
  121. if (Input.GetKeyDown("escape"))
  122. {
  123. Cursor.lockState = CursorLockMode.None;
  124. }
  125.  
  126. if (Input.GetKeyDown("r"))
  127. {
  128. swapCameras();
  129. }
  130. //CAMERA STUFF END
  131. }
  132.  
  133. void swapCameras()
  134. {
  135. //swap booleans
  136. firstPerson = !firstPerson;
  137. thirdPerson = !thirdPerson;
  138.  
  139. //now actually swap the cameras
  140. firstPersonCamera.enabled = !firstPersonCamera.enabled;
  141. thirdPersonCamera.enabled = !firstPersonCamera.enabled;
  142. }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement