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.

359 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. private float DragSave;
  34. //public GameObject magnetTipObject;
  35. //-----------------------
  36. // Use PlayerSound script
  37. // (specifically for object-rotation sounds for this MagnetGun script)
  38. public PlayerSounds _playerSoundScript;
  39. // Use this for initialization
  40. void Start () {
  41. if (topScreen)
  42. playerScreen = 2;
  43. else
  44. playerScreen = -1;
  45. normGrip = playerController.grip;
  46. }
  47. // Update is called once per frame
  48. void Update () {
  49. if (playerController.active) {
  50. float triggerL = Input.GetAxis (L_TRIGGER_INPUT);
  51. float triggerR = Input.GetAxis (R_TRIGGER_INPUT);
  52. Collider target = testItem ();
  53. crossHair.GetComponent<RawImage> ().color = Color.white;
  54. if (target != null) {
  55. if (target.GetComponent<Collider> ().tag == "moveable") {
  56. Debug.Log ("Moveable Item");
  57. crossHair.GetComponent<RawImage> ().color = Color.red;
  58. if (Vector3.Distance (rayHitPoint, camera.transform.position) <= closeRange) {
  59. crossHair.GetComponent<RawImage> ().color = Color.blue;
  60. }
  61. }
  62. }
  63. //updateColors (target);
  64. if (getAxisDown (L_TRIGGER_INPUT)) {
  65. Debug.Log ("axis down");
  66. //Debug.Log (GravityTarget.name);
  67. if (GravityTarget != null) {
  68. dropItem (GravityTarget);
  69. Debug.Log ("dropping item");
  70. } else {
  71. pickUpItem (target);
  72. }
  73. }
  74. /* (triggerL > 0) {
  75. if (!L_Trigger_Down) {
  76. pickUpItem (target);
  77. L_Trigger_Down = true;
  78. }
  79. } else {
  80. L_Trigger_Down = false;
  81. dropItem(GravityTarget);
  82. }
  83. */
  84. if ( GravityTarget == null)
  85. impulsePush (target);
  86. else
  87. pullItem (triggerR);
  88. }
  89. moveItem (GravityTarget);
  90. rotateInput (GravityTarget);
  91. cameraRotateTest (GravityTarget);
  92. }
  93. private Collider testItem(){
  94. RaycastHit hit;
  95. //Vector3 rayDirection = camera.transform.rotation * Vector3.forward;
  96. //Ray ray = camera.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2 + (Screen.height/6 * playerScreen), 0));
  97. Ray ray = camera.ScreenPointToRay(crossHair.transform.position);
  98. Debug.DrawRay (ray.origin, ray.direction*magnetRange, Color.green);
  99. if (Physics.Raycast (ray, out hit, magnetRange)) {
  100. if (hit.collider.tag == "moveable"){
  101. Debug.DrawRay (ray.origin,ray.direction*magnetRange, Color.red);
  102. rayHitPoint = hit.point;
  103. }
  104. }
  105. return hit.collider;
  106. }
  107. private void pickUpItem(Collider item){
  108. if (item != null) {
  109. if (item == otherPlayer.GravityTarget){
  110. otherPlayer.dropItem(item);
  111. }
  112. if (item.tag == "moveable"){
  113. _playerSoundScript.PlayPickUp();
  114. playerController.animator.SetBool("Holding",true);
  115. //playerController.animator.SetTrigger("startHolding");
  116. originalConstrants = item.attachedRigidbody.constraints;
  117. originalGravity = item.attachedRigidbody.useGravity;
  118. item.attachedRigidbody.useGravity = false;
  119. DragSave = item.attachedRigidbody.drag;
  120. item.attachedRigidbody.drag = 3.0f;
  121. item.attachedRigidbody.constraints = RigidbodyConstraints.FreezeRotation | originalConstrants;
  122. //camera.transform.LookAt(item.transform.position);
  123. //playerController.cameraX = camera.transform.eulerAngles.x;
  124. //playerController.cameraY = camera.transform.eulerAngles.y;
  125. gravityWell.transform.position = rayHitPoint;
  126. GravityTarget = item;
  127. targetOffset = GravityTarget.transform.position - rayHitPoint + (Vector3.up * 0.05f);
  128. playerController.slowed = true;
  129. playerController.movementLock = true;
  130. playerController.grip = 15.0f;
  131. if (!topScreen){
  132. playerController.cameraSpeedX = 0.0f;
  133. playerController.cameraSpeedY = 0.0f;
  134. }
  135. }
  136. }
  137. }
  138. private void impulsePush (Collider item){
  139. if (item != null) {
  140. if (item.tag == "moveable" && Input.GetButtonDown("Quick Push")){
  141. if (item == otherPlayer.GravityTarget){
  142. otherPlayer.dropItem(item);
  143. }
  144. Vector3 direction = (transform.position - item.transform.position).normalized;
  145. item.attachedRigidbody.AddForce(direction * impulsePower * maxPullSpeed* item.attachedRigidbody.mass,ForceMode.Impulse );
  146. }
  147. }
  148. }
  149. private void moveItem(Collider item){
  150. if (item != null) {
  151. if (item != playerController.curCollider){
  152. float step = objectSpeed * Time.deltaTime;
  153. Vector3 direction = gravityWell.transform.position - item.transform.position + targetOffset;
  154. direction = Vector3.ClampMagnitude(direction,1.0f);
  155. item.attachedRigidbody.AddForce(direction * objectSpeed * item.attachedRigidbody.mass * Time.deltaTime);
  156. }
  157. }
  158. }
  159. private void dropItem(Collider item){
  160. if (item != null) {
  161. playerController.animator.SetBool("Holding",false);
  162. item.attachedRigidbody.useGravity = originalGravity;
  163. item.attachedRigidbody.drag = DragSave;
  164. item.attachedRigidbody.constraints = originalConstrants;
  165. if(topScreen)
  166. item.attachedRigidbody.velocity = Vector3.ClampMagnitude (item.attachedRigidbody.velocity, 5);
  167. GravityTarget = null;
  168. playerController.slowed = false;
  169. playerController.movementLock = false;
  170. playerController.grip = normGrip;
  171. playerController.cameraSpeedX = 250.0f;
  172. playerController.cameraSpeedY = 120.0f;
  173. }
  174. }
  175. private void pullItem(float speed){
  176. if (!Input.GetButton ("Quick Push"))
  177. return;
  178. float step = maxPullSpeed * 0.5f * Time.deltaTime;
  179. Vector3 maxPull;
  180. maxPull = camera.transform.position + (camera.transform.rotation * Vector3.forward);
  181. if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > minDistance && Vector3.Distance (gravityWell.transform.position, camera.transform.position) < magnetRange) || maxPullSpeed<1) {
  182. gravityWell.transform.position = Vector3.MoveTowards (gravityWell.transform.position, maxPull, step);
  183. //MagnetLaserShoot();
  184. if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > magnetRange) && !topScreen)
  185. dropItem (GravityTarget);
  186. }
  187. }
  188. private void rotateInput(Collider item){
  189. if (item != null) {
  190. if (Input.GetButtonDown(L_BUTTON_INPUT)){
  191. _playerSoundScript.PlayRotateL(); // Rotate-Object Sound. ERROR: Held object continuously rotates
  192. StartCoroutine (rotateItem(item,new Vector3 (0,90,0),0.3f));
  193. }
  194. if (Input.GetButtonDown(R_BUTTON_INPUT)){
  195. _playerSoundScript.PlayRotateR(); // Rotate-Object Sound. ERROR: Held object continuously rotates
  196. StartCoroutine (rotateItem(item,new Vector3 (90,0,0),0.3f));
  197. }
  198. }
  199. }
  200. IEnumerator rotateItem (Collider item, Vector3 byAngles, float inTime){
  201. Quaternion startAngle = item.transform.rotation;
  202. Quaternion endAngle = Quaternion.Euler (item.transform.eulerAngles + byAngles);
  203. for (float i = 0; i < 1; i+=Time.deltaTime/inTime) {
  204. item.transform.rotation = Quaternion.Lerp(startAngle,endAngle,i);
  205. yield return null;
  206. }
  207. }
  208. public void cameraRotateTest(Collider item){
  209. if (item != null) {
  210. //Debug.Log ("distance test: " + Vector3.Distance (gravityWell.transform.position, camera.transform.position));
  211. if (Vector3.Distance (gravityWell.transform.position, camera.transform.position) <= closeRange) {
  212. playerController.cameraSpeedX = 250.0f;
  213. playerController.cameraSpeedY = 120.0f;
  214. } else {
  215. playerController.cameraSpeedX = 0.0f;
  216. playerController.cameraSpeedY = 0.0f;
  217. }
  218. }
  219. }
  220. public void updateColors(Collider target){
  221. if (target != null && target.tag == "moveable") {
  222. lastTargetRenderer = target.GetComponent<Renderer> ();
  223. if (lastTargetRenderer.material.color != Color.white) {
  224. lastTargetColour = lastTargetRenderer.material.color;
  225. lastTargetRenderer.material.color = Color.white;
  226. }
  227. } else {
  228. if (lastTargetRenderer != null)
  229. lastTargetRenderer.material.color = lastTargetColour;
  230. }
  231. }
  232. private bool getAxisDown (string axis){
  233. if( Input.GetAxisRaw(axis) != 0)
  234. {
  235. if(axisDown == false)
  236. {
  237. axisDown = true;
  238. return true;
  239. }
  240. }
  241. if( Input.GetAxisRaw(axis) == 0)
  242. {
  243. axisDown = false;
  244. }
  245. return false;
  246. }
  247. // FUNCTION: Shoot Magnet Ray
  248. // void MagnetLaserShoot(){
  249. // RaycastHit hit;
  250. //
  251. // if(Physics.Raycast(magnetTipObject.transform.position, magnetTipObject.transform.forward, out hit)){
  252. // if(hit.collider.tag == "moveable"){
  253. // Debug.Log("Magnet laser has collided" + hit.collider.gameObject.name);
  254. // }
  255. // }
  256. // }
  257. }