|
@ -20,6 +20,7 @@ public class magnetGun : MonoBehaviour { |
|
|
public GameObject gravityWell; |
|
|
public GameObject gravityWell; |
|
|
private Collider GravityTarget; |
|
|
private Collider GravityTarget; |
|
|
private Vector3 rayHitPoint; |
|
|
private Vector3 rayHitPoint; |
|
|
|
|
|
private Vector3 targetOffset; |
|
|
|
|
|
|
|
|
public float objectSpeed; |
|
|
public float objectSpeed; |
|
|
public float magnetRange = 20; |
|
|
public float magnetRange = 20; |
|
@ -27,6 +28,8 @@ public class magnetGun : MonoBehaviour { |
|
|
public float rotateSpeed; |
|
|
public float rotateSpeed; |
|
|
public float minDistance = 3.0f; |
|
|
public float minDistance = 3.0f; |
|
|
|
|
|
|
|
|
|
|
|
private float maxWalkSpeed; |
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
|
// Use this for initialization
|
|
|
void Start () { |
|
|
void Start () { |
|
|
if (topScreen) |
|
|
if (topScreen) |
|
@ -34,6 +37,8 @@ public class magnetGun : MonoBehaviour { |
|
|
else |
|
|
else |
|
|
playerScreen = -1; |
|
|
playerScreen = -1; |
|
|
|
|
|
|
|
|
|
|
|
maxWalkSpeed = playerController.movementSpeed; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -104,6 +109,8 @@ public class magnetGun : MonoBehaviour { |
|
|
item.attachedRigidbody.constraints = RigidbodyConstraints.FreezeRotation; |
|
|
item.attachedRigidbody.constraints = RigidbodyConstraints.FreezeRotation; |
|
|
gravityWell.transform.position = rayHitPoint; |
|
|
gravityWell.transform.position = rayHitPoint; |
|
|
GravityTarget = item; |
|
|
GravityTarget = item; |
|
|
|
|
|
targetOffset = GravityTarget.transform.position - rayHitPoint + (Vector3.up * 0.05f); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
playerController.movementSpeed = 200.0f; |
|
|
playerController.movementSpeed = 200.0f; |
|
@ -119,7 +126,7 @@ public class magnetGun : MonoBehaviour { |
|
|
private void moveItem(Collider item){ |
|
|
private void moveItem(Collider item){ |
|
|
if (item != null) { |
|
|
if (item != null) { |
|
|
float step = objectSpeed * Time.deltaTime; |
|
|
float step = objectSpeed * Time.deltaTime; |
|
|
Vector3 direction = gravityWell.transform.position - item.transform.position; |
|
|
|
|
|
|
|
|
Vector3 direction = gravityWell.transform.position - item.transform.position + targetOffset; |
|
|
direction = Vector3.ClampMagnitude(direction,1.0f); |
|
|
direction = Vector3.ClampMagnitude(direction,1.0f); |
|
|
|
|
|
|
|
|
item.attachedRigidbody.AddForce(direction * objectSpeed * Time.deltaTime); |
|
|
item.attachedRigidbody.AddForce(direction * objectSpeed * Time.deltaTime); |
|
@ -138,7 +145,7 @@ public class magnetGun : MonoBehaviour { |
|
|
GravityTarget = null; |
|
|
GravityTarget = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
playerController.movementSpeed = 5000.0f; |
|
|
|
|
|
|
|
|
playerController.movementSpeed = maxWalkSpeed; |
|
|
|
|
|
|
|
|
playerController.cameraSpeedX = 250.0f; |
|
|
playerController.cameraSpeedX = 250.0f; |
|
|
playerController.cameraSpeedY = 120.0f; |
|
|
playerController.cameraSpeedY = 120.0f; |
|
|