Browse Source

player now picks up item from where there aiming at not center of object.

master
Joshua Reason 8 years ago
parent
commit
4e06eaa79f
6 changed files with 25 additions and 2 deletions
  1. BIN
      unity_Project/Assets/Materials/Player1.mat
  2. +8
    -0
      unity_Project/Assets/Materials/Player1.mat.meta
  3. +9
    -2
      unity_Project/Assets/Scripts/magnetGun.cs
  4. BIN
      unity_Project/Assets/_Scenes/ScafoldingTest.unity
  5. BIN
      unity_Project/Assets/prefabs/pipe_large1.prefab
  6. +8
    -0
      unity_Project/Assets/prefabs/pipe_large1.prefab.meta

BIN
unity_Project/Assets/Materials/Player1.mat View File


+ 8
- 0
unity_Project/Assets/Materials/Player1.mat.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0fbcbaa69a443464d8f92830db4846ad
timeCreated: 1440752527
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 2
unity_Project/Assets/Scripts/magnetGun.cs View File

@ -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;

BIN
unity_Project/Assets/_Scenes/ScafoldingTest.unity View File


BIN
unity_Project/Assets/prefabs/pipe_large1.prefab View File


+ 8
- 0
unity_Project/Assets/prefabs/pipe_large1.prefab.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c30e3469a139fe646bc1651149e4c505
timeCreated: 1440745563
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save