|
|
@ -40,6 +40,17 @@ public class magnetGun : MonoBehaviour { |
|
|
|
private float normGrip; |
|
|
|
private Renderer lastTargetRenderer; |
|
|
|
private Color lastTargetColour; |
|
|
|
|
|
|
|
|
|
|
|
public GameObject magnetTipObject; |
|
|
|
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// Use PlayerSound script
|
|
|
|
// (specifically for object-rotation sounds for this MagnetGun script)
|
|
|
|
public PlayerSounds _playerSoundScript; |
|
|
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
|
|
void Start () { |
|
|
|
if (topScreen) |
|
|
@ -108,7 +119,6 @@ public class magnetGun : MonoBehaviour { |
|
|
|
cameraRotateTest (GravityTarget); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -138,6 +148,8 @@ public class magnetGun : MonoBehaviour { |
|
|
|
private void pickUpItem(Collider item){ |
|
|
|
if (item != null) { |
|
|
|
|
|
|
|
_playerSoundScript.PlayPickUp(); |
|
|
|
|
|
|
|
if (item == otherPlayer.GravityTarget){ |
|
|
|
otherPlayer.dropItem(item); |
|
|
|
} |
|
|
@ -231,6 +243,7 @@ public class magnetGun : MonoBehaviour { |
|
|
|
|
|
|
|
if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > minDistance && Vector3.Distance (gravityWell.transform.position, camera.transform.position) < magnetRange) || maxPullSpeed<1) { |
|
|
|
gravityWell.transform.position = Vector3.MoveTowards (gravityWell.transform.position, maxPull, step); |
|
|
|
//MagnetLaserShoot();
|
|
|
|
|
|
|
|
if ((Vector3.Distance (gravityWell.transform.position, camera.transform.position) > magnetRange) && !topScreen) |
|
|
|
dropItem (GravityTarget); |
|
|
@ -241,12 +254,19 @@ public class magnetGun : MonoBehaviour { |
|
|
|
private void rotateInput(Collider item){ |
|
|
|
if (item != null) { |
|
|
|
if (Input.GetButtonDown(L_BUTTON_INPUT)) |
|
|
|
//_playerSoundScript.PlayRotateL(); // Rotate-Object Sound. ERROR: Held object continuously rotates
|
|
|
|
StartCoroutine (rotateItem(item,new Vector3 (0,90,0),0.3f)); |
|
|
|
|
|
|
|
if (Input.GetButtonDown(R_BUTTON_INPUT)) |
|
|
|
//_playerSoundScript.PlayRotateR(); // Rotate-Object Sound. ERROR: Held object continuously rotates
|
|
|
|
StartCoroutine (rotateItem(item,new Vector3 (90,0,0),0.3f)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator rotateItem (Collider item, Vector3 byAngles, float inTime){ |
|
|
|
|
|
|
|
Quaternion startAngle = item.transform.rotation; |
|
|
@ -310,5 +330,20 @@ public class magnetGun : MonoBehaviour { |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FUNCTION: Shoot Magnet Ray
|
|
|
|
// void MagnetLaserShoot(){
|
|
|
|
// RaycastHit hit;
|
|
|
|
//
|
|
|
|
// if(Physics.Raycast(magnetTipObject.transform.position, magnetTipObject.transform.forward, out hit)){
|
|
|
|
// if(hit.collider.tag == "moveable"){
|
|
|
|
// Debug.Log("Magnet laser has collided" + hit.collider.gameObject.name);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |