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.

358 lines
9.0 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.
8 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.
8 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.
8 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.SetTrigger("startHolding");
  114. playerController.animator.SetBool("Holding",true);
  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.SetTrigger("stopHolding");
  160. playerController.animator.SetBool("Holding",false);
  161. item.attachedRigidbody.useGravity = originalGravity;
  162. item.attachedRigidbody.drag = 0.0f;
  163. item.attachedRigidbody.constraints = originalConstrants;
  164. if(topScreen)
  165. item.attachedRigidbody.velocity = Vector3.ClampMagnitude (item.attachedRigidbody.velocity, 5);
  166. GravityTarget = null;
  167. playerController.slowed = false;
  168. playerController.movementLock = false;
  169. playerController.grip = normGrip;
  170. playerController.cameraSpeedX = 250.0f;
  171. playerController.cameraSpeedY = 120.0f;
  172. }
  173. }
  174. private void pullItem(float speed){
  175. if (!Input.GetButton ("Quick Push"))
  176. return;
  177. float step = maxPullSpeed * 0.5f * Time.deltaTime;
  178. Vector3 maxPull;
  179. maxPull = camera.transform.position + (camera.transform.rotation * Vector3.forward);
  180. if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > minDistance && Vector3.Distance (gravityWell.transform.position, camera.transform.position) < magnetRange) || maxPullSpeed<1) {
  181. gravityWell.transform.position = Vector3.MoveTowards (gravityWell.transform.position, maxPull, step);
  182. //MagnetLaserShoot();
  183. if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > magnetRange) && !topScreen)
  184. dropItem (GravityTarget);
  185. }
  186. }
  187. private void rotateInput(Collider item){
  188. if (item != null) {
  189. if (Input.GetButtonDown(L_BUTTON_INPUT))
  190. //_playerSoundScript.PlayRotateL(); // Rotate-Object Sound. ERROR: Held object continuously rotates
  191. StartCoroutine (rotateItem(item,new Vector3 (0,90,0),0.3f));
  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. IEnumerator rotateItem (Collider item, Vector3 byAngles, float inTime){
  198. Quaternion startAngle = item.transform.rotation;
  199. Quaternion endAngle = Quaternion.Euler (item.transform.eulerAngles + byAngles);
  200. for (float i = 0; i < 1; i+=Time.deltaTime/inTime) {
  201. item.transform.rotation = Quaternion.Lerp(startAngle,endAngle,i);
  202. yield return null;
  203. }
  204. }
  205. public void cameraRotateTest(Collider item){
  206. if (item != null) {
  207. //Debug.Log ("distance test: " + Vector3.Distance (gravityWell.transform.position, camera.transform.position));
  208. if (Vector3.Distance (gravityWell.transform.position, camera.transform.position) <= closeRange) {
  209. playerController.cameraSpeedX = 250.0f;
  210. playerController.cameraSpeedY = 120.0f;
  211. } else {
  212. playerController.cameraSpeedX = 0.0f;
  213. playerController.cameraSpeedY = 0.0f;
  214. }
  215. }
  216. }
  217. public void updateColors(Collider target){
  218. if (target != null && target.tag == "moveable") {
  219. lastTargetRenderer = target.GetComponent<Renderer> ();
  220. if (lastTargetRenderer.material.color != Color.white) {
  221. lastTargetColour = lastTargetRenderer.material.color;
  222. lastTargetRenderer.material.color = Color.white;
  223. }
  224. } else {
  225. if (lastTargetRenderer != null)
  226. lastTargetRenderer.material.color = lastTargetColour;
  227. }
  228. }
  229. private bool getAxisDown (string axis){
  230. if( Input.GetAxisRaw(axis) != 0)
  231. {
  232. if(axisDown == false)
  233. {
  234. axisDown = true;
  235. return true;
  236. }
  237. }
  238. if( Input.GetAxisRaw(axis) == 0)
  239. {
  240. axisDown = false;
  241. }
  242. return false;
  243. }
  244. // FUNCTION: Shoot Magnet Ray
  245. // void MagnetLaserShoot(){
  246. // RaycastHit hit;
  247. //
  248. // if(Physics.Raycast(magnetTipObject.transform.position, magnetTipObject.transform.forward, out hit)){
  249. // if(hit.collider.tag == "moveable"){
  250. // Debug.Log("Magnet laser has collided" + hit.collider.gameObject.name);
  251. // }
  252. // }
  253. // }
  254. }