You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
8.8 KiB

ADDED: + Script: PlayerSounds + Texture: Magnet Rods (Pull & Push) + GUI Image: Game Logo (not yet implemented in UI) + Unity Scene: Title Screen + SFX: Footsteps (sand), test beep, switch-player sound, wind ambience + BGM: Just Dessert (2nd Part) (This was cut from previous facebook mp3 upload) Purely for testing purposes. + Audio Source for wind ambience sounds CHANGED: > A duplicate of "Cycle Run" was made so that sound events can be keyframed into the running animation (FBX-animations were initially read-only) > Added "PlayFootstep" sound event to running animation. > Changed invisible wall positions near the starting point area > Slightly lowered the first concrete platform's position near the long metal beam and small crates > Slightly increased the height of the first fences > Added small bits of terrain hills to create "distant cliff illusion" > SceneController script now has connection with PlayerSound script to allow switch-player sound > MagnetGun script (Player 1) now has connection with PlayerSound script to allow object-rotation sound > Added an Audio Source to the Player 1 Avatar object. All player sounds are assigned to this component. NOTE: > Only Player 1 has some sounds. Player 2 will have sounds once Player 1 has 100% sounds. > Cutscene management will need to be discussed. Unsure whether single-scene camera changes are possible and easy to implement due to script structure. Having a cutscene in a seperate scene will be demanding, processor-wise, but can be done. > Still have not received updated movable object textures at this time. Way past its deadline. KNOWN ISSUES: - On my Gaming PC, playing the game for an extended amount of time can cause the frame rate to flacuate from 30 to 60fps at set intervals of approximatelly every 5sec. - The above issue can be mitigated via restarting your PC. FPS issues could possibly be caused by junk metadata build-up. - The above issue has also been found in week #8 playtest build.
9 years ago
ADDED: + Script: PlayerSounds + Texture: Magnet Rods (Pull & Push) + GUI Image: Game Logo (not yet implemented in UI) + Unity Scene: Title Screen + SFX: Footsteps (sand), test beep, switch-player sound, wind ambience + BGM: Just Dessert (2nd Part) (This was cut from previous facebook mp3 upload) Purely for testing purposes. + Audio Source for wind ambience sounds CHANGED: > A duplicate of "Cycle Run" was made so that sound events can be keyframed into the running animation (FBX-animations were initially read-only) > Added "PlayFootstep" sound event to running animation. > Changed invisible wall positions near the starting point area > Slightly lowered the first concrete platform's position near the long metal beam and small crates > Slightly increased the height of the first fences > Added small bits of terrain hills to create "distant cliff illusion" > SceneController script now has connection with PlayerSound script to allow switch-player sound > MagnetGun script (Player 1) now has connection with PlayerSound script to allow object-rotation sound > Added an Audio Source to the Player 1 Avatar object. All player sounds are assigned to this component. NOTE: > Only Player 1 has some sounds. Player 2 will have sounds once Player 1 has 100% sounds. > Cutscene management will need to be discussed. Unsure whether single-scene camera changes are possible and easy to implement due to script structure. Having a cutscene in a seperate scene will be demanding, processor-wise, but can be done. > Still have not received updated movable object textures at this time. Way past its deadline. KNOWN ISSUES: - On my Gaming PC, playing the game for an extended amount of time can cause the frame rate to flacuate from 30 to 60fps at set intervals of approximatelly every 5sec. - The above issue can be mitigated via restarting your PC. FPS issues could possibly be caused by junk metadata build-up. - The above issue has also been found in week #8 playtest build.
9 years ago
ADDED: + Script: PlayerSounds + Texture: Magnet Rods (Pull & Push) + GUI Image: Game Logo (not yet implemented in UI) + Unity Scene: Title Screen + SFX: Footsteps (sand), test beep, switch-player sound, wind ambience + BGM: Just Dessert (2nd Part) (This was cut from previous facebook mp3 upload) Purely for testing purposes. + Audio Source for wind ambience sounds CHANGED: > A duplicate of "Cycle Run" was made so that sound events can be keyframed into the running animation (FBX-animations were initially read-only) > Added "PlayFootstep" sound event to running animation. > Changed invisible wall positions near the starting point area > Slightly lowered the first concrete platform's position near the long metal beam and small crates > Slightly increased the height of the first fences > Added small bits of terrain hills to create "distant cliff illusion" > SceneController script now has connection with PlayerSound script to allow switch-player sound > MagnetGun script (Player 1) now has connection with PlayerSound script to allow object-rotation sound > Added an Audio Source to the Player 1 Avatar object. All player sounds are assigned to this component. NOTE: > Only Player 1 has some sounds. Player 2 will have sounds once Player 1 has 100% sounds. > Cutscene management will need to be discussed. Unsure whether single-scene camera changes are possible and easy to implement due to script structure. Having a cutscene in a seperate scene will be demanding, processor-wise, but can be done. > Still have not received updated movable object textures at this time. Way past its deadline. KNOWN ISSUES: - On my Gaming PC, playing the game for an extended amount of time can cause the frame rate to flacuate from 30 to 60fps at set intervals of approximatelly every 5sec. - The above issue can be mitigated via restarting your PC. FPS issues could possibly be caused by junk metadata build-up. - The above issue has also been found in week #8 playtest build.
9 years ago
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. public class magnetGun : MonoBehaviour {
  5. public Camera camera;
  6. public GameObject crossHair;
  7. public thirdPersonController playerController;
  8. public magnetGun otherPlayer;
  9. public string L_TRIGGER_INPUT;
  10. public string R_TRIGGER_INPUT;
  11. public string L_BUTTON_INPUT;
  12. public string R_BUTTON_INPUT;
  13. private bool L_Trigger_Down;
  14. public bool topScreen = true;
  15. private float playerScreen = 2;
  16. public GameObject gravityWell;
  17. public Collider GravityTarget;
  18. private Vector3 rayHitPoint;
  19. private Vector3 targetOffset;
  20. public float objectSpeed;
  21. public float magnetRange = 20;
  22. public float maxPullSpeed = 30;
  23. public float rotateSpeed;
  24. public float minDistance = 3.0f;
  25. public float closeRange = 5.0f;
  26. public float impulsePower = 50.0f;
  27. private RigidbodyConstraints originalConstrants;
  28. private bool originalGravity;
  29. private bool axisDown = false;
  30. private float normGrip;
  31. private Renderer lastTargetRenderer;
  32. private Color lastTargetColour;
  33. public GameObject magnetTipObject;
  34. //-----------------------
  35. // Use PlayerSound script
  36. // (specifically for object-rotation sounds for this MagnetGun script)
  37. public PlayerSounds _playerSoundScript;
  38. // Use this for initialization
  39. void Start () {
  40. if (topScreen)
  41. playerScreen = 2;
  42. else
  43. playerScreen = -1;
  44. normGrip = playerController.grip;
  45. }
  46. // Update is called once per frame
  47. void Update () {
  48. if (playerController.active) {
  49. float triggerL = Input.GetAxis (L_TRIGGER_INPUT);
  50. float triggerR = Input.GetAxis (R_TRIGGER_INPUT);
  51. Collider target = testItem ();
  52. crossHair.GetComponent<RawImage> ().color = Color.white;
  53. if (target != null) {
  54. if (target.GetComponent<Collider> ().tag == "moveable") {
  55. Debug.Log ("Moveable Item");
  56. crossHair.GetComponent<RawImage> ().color = Color.red;
  57. if (Vector3.Distance (rayHitPoint, camera.transform.position) <= closeRange) {
  58. crossHair.GetComponent<RawImage> ().color = Color.blue;
  59. }
  60. }
  61. }
  62. updateColors (target);
  63. if (getAxisDown (L_TRIGGER_INPUT)) {
  64. Debug.Log ("axis down");
  65. //Debug.Log (GravityTarget.name);
  66. if (GravityTarget != null) {
  67. dropItem (GravityTarget);
  68. Debug.Log ("dropping item");
  69. } else {
  70. pickUpItem (target);
  71. }
  72. }
  73. /* (triggerL > 0) {
  74. if (!L_Trigger_Down) {
  75. pickUpItem (target);
  76. L_Trigger_Down = true;
  77. }
  78. } else {
  79. L_Trigger_Down = false;
  80. dropItem(GravityTarget);
  81. }
  82. */
  83. if ( GravityTarget == null)
  84. impulsePush (target);
  85. else
  86. pullItem (triggerR);
  87. }
  88. moveItem (GravityTarget);
  89. rotateInput (GravityTarget);
  90. cameraRotateTest (GravityTarget);
  91. }
  92. private Collider testItem(){
  93. RaycastHit hit;
  94. //Vector3 rayDirection = camera.transform.rotation * Vector3.forward;
  95. //Ray ray = camera.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2 + (Screen.height/6 * playerScreen), 0));
  96. Ray ray = camera.ScreenPointToRay(crossHair.transform.position);
  97. Debug.DrawRay (ray.origin, ray.direction*magnetRange, Color.green);
  98. if (Physics.Raycast (ray, out hit, magnetRange)) {
  99. if (hit.collider.tag == "moveable"){
  100. Debug.DrawRay (ray.origin,ray.direction*magnetRange, Color.red);
  101. rayHitPoint = hit.point;
  102. }
  103. }
  104. return hit.collider;
  105. }
  106. private void pickUpItem(Collider item){
  107. if (item != null) {
  108. //_playerSoundScript.PlayPickUp();
  109. if (item == otherPlayer.GravityTarget){
  110. otherPlayer.dropItem(item);
  111. }
  112. if (item.tag == "moveable"){
  113. originalConstrants = item.attachedRigidbody.constraints;
  114. originalGravity = item.attachedRigidbody.useGravity;
  115. item.attachedRigidbody.useGravity = false;
  116. item.attachedRigidbody.drag = 3.0f;
  117. item.attachedRigidbody.constraints = RigidbodyConstraints.FreezeRotation | originalConstrants;
  118. //camera.transform.LookAt(item.transform.position);
  119. //playerController.cameraX = camera.transform.eulerAngles.x;
  120. //playerController.cameraY = camera.transform.eulerAngles.y;
  121. gravityWell.transform.position = rayHitPoint;
  122. GravityTarget = item;
  123. targetOffset = GravityTarget.transform.position - rayHitPoint + (Vector3.up * 0.05f);
  124. playerController.slowed = true;
  125. playerController.movementLock = true;
  126. playerController.grip = 15.0f;
  127. if (!topScreen){
  128. playerController.cameraSpeedX = 0.0f;
  129. playerController.cameraSpeedY = 0.0f;
  130. }
  131. }
  132. }
  133. }
  134. private void impulsePush (Collider item){
  135. if (item != null) {
  136. if (item.tag == "moveable" && Input.GetButtonDown("Quick Push")){
  137. if (item == otherPlayer.GravityTarget){
  138. otherPlayer.dropItem(item);
  139. }
  140. Vector3 direction = (transform.position - item.transform.position).normalized;
  141. item.attachedRigidbody.AddForce(direction * impulsePower * maxPullSpeed* item.attachedRigidbody.mass,ForceMode.Impulse );
  142. }
  143. }
  144. }
  145. private void moveItem(Collider item){
  146. if (item != null) {
  147. if (item != playerController.curCollider){
  148. float step = objectSpeed * Time.deltaTime;
  149. Vector3 direction = gravityWell.transform.position - item.transform.position + targetOffset;
  150. direction = Vector3.ClampMagnitude(direction,1.0f);
  151. item.attachedRigidbody.AddForce(direction * objectSpeed * Time.deltaTime);
  152. }
  153. }
  154. }
  155. private void dropItem(Collider item){
  156. if (item != null) {
  157. item.attachedRigidbody.useGravity = originalGravity;
  158. item.attachedRigidbody.drag = 0.0f;
  159. item.attachedRigidbody.constraints = originalConstrants;
  160. if(topScreen)
  161. item.attachedRigidbody.velocity = Vector3.ClampMagnitude (item.attachedRigidbody.velocity, 5);
  162. GravityTarget = null;
  163. playerController.slowed = false;
  164. playerController.movementLock = false;
  165. playerController.grip = normGrip;
  166. playerController.cameraSpeedX = 250.0f;
  167. playerController.cameraSpeedY = 120.0f;
  168. }
  169. }
  170. private void pullItem(float speed){
  171. if (!Input.GetButton ("Quick Push"))
  172. return;
  173. float step = maxPullSpeed * 0.5f * Time.deltaTime;
  174. Vector3 maxPull;
  175. maxPull = camera.transform.position + (camera.transform.rotation * Vector3.forward);
  176. if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > minDistance && Vector3.Distance (gravityWell.transform.position, camera.transform.position) < magnetRange) || maxPullSpeed<1) {
  177. gravityWell.transform.position = Vector3.MoveTowards (gravityWell.transform.position, maxPull, step);
  178. //MagnetLaserShoot();
  179. if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > magnetRange) && !topScreen)
  180. dropItem (GravityTarget);
  181. }
  182. }
  183. private void rotateInput(Collider item){
  184. if (item != null) {
  185. if (Input.GetButtonDown(L_BUTTON_INPUT))
  186. //_playerSoundScript.PlayRotateL(); // Rotate-Object Sound. ERROR: Held object continuously rotates
  187. StartCoroutine (rotateItem(item,new Vector3 (0,90,0),0.3f));
  188. if (Input.GetButtonDown(R_BUTTON_INPUT))
  189. //_playerSoundScript.PlayRotateR(); // Rotate-Object Sound. ERROR: Held object continuously rotates
  190. StartCoroutine (rotateItem(item,new Vector3 (90,0,0),0.3f));
  191. }
  192. }
  193. IEnumerator rotateItem (Collider item, Vector3 byAngles, float inTime){
  194. Quaternion startAngle = item.transform.rotation;
  195. Quaternion endAngle = Quaternion.Euler (item.transform.eulerAngles + byAngles);
  196. for (float i = 0; i < 1; i+=Time.deltaTime/inTime) {
  197. item.transform.rotation = Quaternion.Lerp(startAngle,endAngle,i);
  198. yield return null;
  199. }
  200. }
  201. public void cameraRotateTest(Collider item){
  202. if (item != null) {
  203. //Debug.Log ("distance test: " + Vector3.Distance (gravityWell.transform.position, camera.transform.position));
  204. if (Vector3.Distance (gravityWell.transform.position, camera.transform.position) <= closeRange) {
  205. playerController.cameraSpeedX = 250.0f;
  206. playerController.cameraSpeedY = 120.0f;
  207. } else {
  208. playerController.cameraSpeedX = 0.0f;
  209. playerController.cameraSpeedY = 0.0f;
  210. }
  211. }
  212. }
  213. public void updateColors(Collider target){
  214. if (target != null && target.tag == "moveable") {
  215. lastTargetRenderer = target.GetComponent<Renderer> ();
  216. if (lastTargetRenderer.material.color != Color.white) {
  217. lastTargetColour = lastTargetRenderer.material.color;
  218. lastTargetRenderer.material.color = Color.white;
  219. }
  220. } else {
  221. if (lastTargetRenderer != null)
  222. lastTargetRenderer.material.color = lastTargetColour;
  223. }
  224. }
  225. private bool getAxisDown (string axis){
  226. if( Input.GetAxisRaw(axis) != 0)
  227. {
  228. if(axisDown == false)
  229. {
  230. axisDown = true;
  231. return true;
  232. }
  233. }
  234. if( Input.GetAxisRaw(axis) == 0)
  235. {
  236. axisDown = false;
  237. }
  238. return false;
  239. }
  240. // FUNCTION: Shoot Magnet Ray
  241. // void MagnetLaserShoot(){
  242. // RaycastHit hit;
  243. //
  244. // if(Physics.Raycast(magnetTipObject.transform.position, magnetTipObject.transform.forward, out hit)){
  245. // if(hit.collider.tag == "moveable"){
  246. // Debug.Log("Magnet laser has collided" + hit.collider.gameObject.name);
  247. // }
  248. // }
  249. // }
  250. }