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.

357 lines
8.9 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. playerController.animator.SetBool("Holding",true);
  114. //playerController.animator.SetTrigger("startHolding");
  115. originalConstrants = item.attachedRigidbody.constraints;
  116. originalGravity = item.attachedRigidbody.useGravity;
  117. item.attachedRigidbody.useGravity = false;
  118. item.attachedRigidbody.drag = 3.0f;
  119. item.attachedRigidbody.constraints = RigidbodyConstraints.FreezeRotation | originalConstrants;
  120. //camera.transform.LookAt(item.transform.position);
  121. //playerController.cameraX = camera.transform.eulerAngles.x;
  122. //playerController.cameraY = camera.transform.eulerAngles.y;
  123. gravityWell.transform.position = rayHitPoint;
  124. GravityTarget = item;
  125. targetOffset = GravityTarget.transform.position - rayHitPoint + (Vector3.up * 0.05f);
  126. playerController.slowed = true;
  127. playerController.movementLock = true;
  128. playerController.grip = 15.0f;
  129. if (!topScreen){
  130. playerController.cameraSpeedX = 0.0f;
  131. playerController.cameraSpeedY = 0.0f;
  132. }
  133. }
  134. }
  135. }
  136. private void impulsePush (Collider item){
  137. if (item != null) {
  138. if (item.tag == "moveable" && Input.GetButtonDown("Quick Push")){
  139. if (item == otherPlayer.GravityTarget){
  140. otherPlayer.dropItem(item);
  141. }
  142. Vector3 direction = (transform.position - item.transform.position).normalized;
  143. item.attachedRigidbody.AddForce(direction * impulsePower * maxPullSpeed* item.attachedRigidbody.mass,ForceMode.Impulse );
  144. }
  145. }
  146. }
  147. private void moveItem(Collider item){
  148. if (item != null) {
  149. if (item != playerController.curCollider){
  150. float step = objectSpeed * Time.deltaTime;
  151. Vector3 direction = gravityWell.transform.position - item.transform.position + targetOffset;
  152. direction = Vector3.ClampMagnitude(direction,1.0f);
  153. item.attachedRigidbody.AddForce(direction * objectSpeed * Time.deltaTime);
  154. }
  155. }
  156. }
  157. private void dropItem(Collider item){
  158. if (item != null) {
  159. playerController.animator.SetBool("Holding",false);
  160. item.attachedRigidbody.useGravity = originalGravity;
  161. item.attachedRigidbody.drag = 0.0f;
  162. item.attachedRigidbody.constraints = originalConstrants;
  163. if(topScreen)
  164. item.attachedRigidbody.velocity = Vector3.ClampMagnitude (item.attachedRigidbody.velocity, 5);
  165. GravityTarget = null;
  166. playerController.slowed = false;
  167. playerController.movementLock = false;
  168. playerController.grip = normGrip;
  169. playerController.cameraSpeedX = 250.0f;
  170. playerController.cameraSpeedY = 120.0f;
  171. }
  172. }
  173. private void pullItem(float speed){
  174. if (!Input.GetButton ("Quick Push"))
  175. return;
  176. float step = maxPullSpeed * 0.5f * Time.deltaTime;
  177. Vector3 maxPull;
  178. maxPull = camera.transform.position + (camera.transform.rotation * Vector3.forward);
  179. if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > minDistance && Vector3.Distance (gravityWell.transform.position, camera.transform.position) < magnetRange) || maxPullSpeed<1) {
  180. gravityWell.transform.position = Vector3.MoveTowards (gravityWell.transform.position, maxPull, step);
  181. //MagnetLaserShoot();
  182. if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > magnetRange) && !topScreen)
  183. dropItem (GravityTarget);
  184. }
  185. }
  186. private void rotateInput(Collider item){
  187. if (item != null) {
  188. if (Input.GetButtonDown(L_BUTTON_INPUT)){
  189. _playerSoundScript.PlayRotateL(); // Rotate-Object Sound. ERROR: Held object continuously rotates
  190. StartCoroutine (rotateItem(item,new Vector3 (0,90,0),0.3f));
  191. }
  192. if (Input.GetButtonDown(R_BUTTON_INPUT)){
  193. _playerSoundScript.PlayRotateR(); // Rotate-Object Sound. ERROR: Held object continuously rotates
  194. StartCoroutine (rotateItem(item,new Vector3 (90,0,0),0.3f));
  195. }
  196. }
  197. }
  198. IEnumerator rotateItem (Collider item, Vector3 byAngles, float inTime){
  199. Quaternion startAngle = item.transform.rotation;
  200. Quaternion endAngle = Quaternion.Euler (item.transform.eulerAngles + byAngles);
  201. for (float i = 0; i < 1; i+=Time.deltaTime/inTime) {
  202. item.transform.rotation = Quaternion.Lerp(startAngle,endAngle,i);
  203. yield return null;
  204. }
  205. }
  206. public void cameraRotateTest(Collider item){
  207. if (item != null) {
  208. //Debug.Log ("distance test: " + Vector3.Distance (gravityWell.transform.position, camera.transform.position));
  209. if (Vector3.Distance (gravityWell.transform.position, camera.transform.position) <= closeRange) {
  210. playerController.cameraSpeedX = 250.0f;
  211. playerController.cameraSpeedY = 120.0f;
  212. } else {
  213. playerController.cameraSpeedX = 0.0f;
  214. playerController.cameraSpeedY = 0.0f;
  215. }
  216. }
  217. }
  218. public void updateColors(Collider target){
  219. if (target != null && target.tag == "moveable") {
  220. lastTargetRenderer = target.GetComponent<Renderer> ();
  221. if (lastTargetRenderer.material.color != Color.white) {
  222. lastTargetColour = lastTargetRenderer.material.color;
  223. lastTargetRenderer.material.color = Color.white;
  224. }
  225. } else {
  226. if (lastTargetRenderer != null)
  227. lastTargetRenderer.material.color = lastTargetColour;
  228. }
  229. }
  230. private bool getAxisDown (string axis){
  231. if( Input.GetAxisRaw(axis) != 0)
  232. {
  233. if(axisDown == false)
  234. {
  235. axisDown = true;
  236. return true;
  237. }
  238. }
  239. if( Input.GetAxisRaw(axis) == 0)
  240. {
  241. axisDown = false;
  242. }
  243. return false;
  244. }
  245. // FUNCTION: Shoot Magnet Ray
  246. // void MagnetLaserShoot(){
  247. // RaycastHit hit;
  248. //
  249. // if(Physics.Raycast(magnetTipObject.transform.position, magnetTipObject.transform.forward, out hit)){
  250. // if(hit.collider.tag == "moveable"){
  251. // Debug.Log("Magnet laser has collided" + hit.collider.gameObject.name);
  252. // }
  253. // }
  254. // }
  255. }