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