Browse Source

-Updated controls,

-fixed bugs
master
Joshua Reason 9 years ago
parent
commit
d4f832b584
13 changed files with 266 additions and 110452 deletions
  1. +182
    -110411
      Experiment Files/Assignment2_Demo_Data/output_log.txt
  2. BIN
      unity_Project/Assets/Character/Character_Animation.controller
  3. BIN
      unity_Project/Assets/GUI Assets/Icon - PULL.controller
  4. BIN
      unity_Project/Assets/GUI Assets/Icon - PUSH.controller
  5. BIN
      unity_Project/Assets/GUI Assets/icon_PULL_invisible.anim
  6. BIN
      unity_Project/Assets/GUI Assets/icon_PUSH_invisible.anim
  7. +52
    -35
      unity_Project/Assets/Scripts/magnetGun.cs
  8. +1
    -1
      unity_Project/Assets/Scripts/playerFollow.cs
  9. +4
    -0
      unity_Project/Assets/Scripts/sceneController.cs
  10. +26
    -4
      unity_Project/Assets/Scripts/thirdPersonController.cs
  11. BIN
      unity_Project/Assets/_Scenes/MainLevel.unity
  12. BIN
      unity_Project/ProjectSettings/ProjectSettings.asset
  13. +1
    -1
      unity_Project/ProjectSettings/ProjectVersion.txt

+ 182
- 110411
Experiment Files/Assignment2_Demo_Data/output_log.txt
File diff suppressed because it is too large
View File


BIN
unity_Project/Assets/Character/Character_Animation.controller View File


BIN
unity_Project/Assets/GUI Assets/Icon - PULL.controller View File


BIN
unity_Project/Assets/GUI Assets/Icon - PUSH.controller View File


BIN
unity_Project/Assets/GUI Assets/icon_PULL_invisible.anim View File


BIN
unity_Project/Assets/GUI Assets/icon_PUSH_invisible.anim View File


+ 52
- 35
unity_Project/Assets/Scripts/magnetGun.cs View File

@ -28,6 +28,7 @@ public class magnetGun : MonoBehaviour {
public float maxPullSpeed = 30;
public float rotateSpeed;
public float minDistance = 3.0f;
public float closeRange = 5.0f;
public float impulsePower = 50.0f;
private RigidbodyConstraints originalConstrants;
@ -54,39 +55,40 @@ public class magnetGun : MonoBehaviour {
// Update is called once per frame
void Update () {
float triggerL = Input.GetAxis(L_TRIGGER_INPUT);
float triggerR = Input.GetAxis (R_TRIGGER_INPUT);
if (playerController.active) {
float triggerL = Input.GetAxis (L_TRIGGER_INPUT);
float triggerR = Input.GetAxis (R_TRIGGER_INPUT);
Collider target = testItem ();
Collider target = testItem ();
crossHair.GetComponent<RawImage> ().color = Color.white;
if (target != null){
if (target.GetComponent<Collider>().tag == "moveable"){
Debug.Log("Moveable Item");
crossHair.GetComponent<RawImage>().color = Color.red;
if (Vector3.Distance (rayHitPoint, camera.transform.position) <= minDistance) {
crossHair.GetComponent<RawImage>().color = Color.blue;
crossHair.GetComponent<RawImage> ().color = Color.white;
if (target != null) {
if (target.GetComponent<Collider> ().tag == "moveable") {
Debug.Log ("Moveable Item");
crossHair.GetComponent<RawImage> ().color = Color.red;
if (Vector3.Distance (rayHitPoint, camera.transform.position) <= closeRange) {
crossHair.GetComponent<RawImage> ().color = Color.blue;
}
}
}
}
updateColors (target);
updateColors (target);
if (getAxisDown(L_TRIGGER_INPUT)){
Debug.Log ("axis down");
//Debug.Log (GravityTarget.name);
if (getAxisDown (L_TRIGGER_INPUT)) {
Debug.Log ("axis down");
//Debug.Log (GravityTarget.name);
if (GravityTarget != null){
dropItem (GravityTarget);
Debug.Log("dropping item");
}else{
pickUpItem (target);
if (GravityTarget != null) {
dropItem (GravityTarget);
Debug.Log ("dropping item");
} else {
pickUpItem (target);
}
}
}
/* (triggerL > 0) {
/* (triggerL > 0) {
if (!L_Trigger_Down) {
pickUpItem (target);
L_Trigger_Down = true;
@ -96,9 +98,12 @@ public class magnetGun : MonoBehaviour {
dropItem(GravityTarget);
}
*/
impulsePush (target);
if ( GravityTarget == null)
impulsePush (target);
else
pullItem (triggerR);
}
moveItem (GravityTarget);
pullItem (triggerR);
rotateInput (GravityTarget);
cameraRotateTest (GravityTarget);
@ -153,8 +158,9 @@ public class magnetGun : MonoBehaviour {
targetOffset = GravityTarget.transform.position - rayHitPoint + (Vector3.up * 0.05f);
playerController.immobile = true;
playerController.grip = 100.0f;
playerController.slowed = true;
playerController.movementLock = true;
playerController.grip = 15.0f;
if (!topScreen){
playerController.cameraSpeedX = 0.0f;
@ -166,7 +172,13 @@ public class magnetGun : MonoBehaviour {
private void impulsePush (Collider item){
if (item != null) {
if (item.tag == "moveable" && Input.GetButtonDown("Quick Push")){
if (item == otherPlayer.GravityTarget){
otherPlayer.dropItem(item);
}
Vector3 direction = (transform.position - item.transform.position).normalized;
item.attachedRigidbody.AddForce(direction * impulsePower * maxPullSpeed* item.attachedRigidbody.mass,ForceMode.Impulse );
@ -175,13 +187,14 @@ 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 + targetOffset;
direction = Vector3.ClampMagnitude(direction,1.0f);
item.attachedRigidbody.AddForce(direction * objectSpeed * Time.deltaTime);
if (item != null) {
if (item != playerController.curCollider){
float step = objectSpeed * Time.deltaTime;
Vector3 direction = gravityWell.transform.position - item.transform.position + targetOffset;
direction = Vector3.ClampMagnitude(direction,1.0f);
item.attachedRigidbody.AddForce(direction * objectSpeed * Time.deltaTime);
}
}
}
@ -195,7 +208,8 @@ public class magnetGun : MonoBehaviour {
item.attachedRigidbody.velocity = Vector3.ClampMagnitude (item.attachedRigidbody.velocity, 5);
GravityTarget = null;
playerController.immobile = false;
playerController.slowed = false;
playerController.movementLock = false;
playerController.grip = normGrip;
playerController.cameraSpeedX = 250.0f;
@ -206,7 +220,10 @@ public class magnetGun : MonoBehaviour {
private void pullItem(float speed){
float step = maxPullSpeed * speed * Time.deltaTime;
if (!Input.GetButton ("Quick Push"))
return;
float step = maxPullSpeed * 0.5f * Time.deltaTime;
Vector3 maxPull;
maxPull = camera.transform.position + (camera.transform.rotation * Vector3.forward);
@ -247,7 +264,7 @@ public class magnetGun : MonoBehaviour {
if (item != null) {
//Debug.Log ("distance test: " + Vector3.Distance (gravityWell.transform.position, camera.transform.position));
if (Vector3.Distance (gravityWell.transform.position, camera.transform.position) <= minDistance) {
if (Vector3.Distance (gravityWell.transform.position, camera.transform.position) <= closeRange) {
playerController.cameraSpeedX = 250.0f;
playerController.cameraSpeedY = 120.0f;
} else {

+ 1
- 1
unity_Project/Assets/Scripts/playerFollow.cs View File

@ -7,7 +7,7 @@ public class playerFollow : MonoBehaviour {
public float minDistance = 4;
public bool active;
private bool follow = false;
bool follow = false;
private Rigidbody rigidbody;
private thirdPersonController playerController;

+ 4
- 0
unity_Project/Assets/Scripts/sceneController.cs View File

@ -11,6 +11,8 @@ public class sceneController : MonoBehaviour {
public GameObject crossHairPlayer1;
public GameObject crossHairPlayer2;
public GameObject playerPointer;
public Animator push;
public Animator pull;
public float screenAnimationTime;
@ -76,6 +78,7 @@ public class sceneController : MonoBehaviour {
oldCamera = cameraPlayer2;
crossHairPlayer1.SetActive(true);
crossHairPlayer2.SetActive(false);
pull.SetTrigger("appear");
@ -84,6 +87,7 @@ public class sceneController : MonoBehaviour {
oldCamera = cameraPlayer1;
crossHairPlayer1.SetActive(false);
crossHairPlayer2.SetActive(true);
push.SetTrigger("appear");
}

+ 26
- 4
unity_Project/Assets/Scripts/thirdPersonController.cs View File

@ -20,12 +20,13 @@ public class thirdPersonController : MonoBehaviour {
public bool active = true;
public float movementSpeed;
public bool movementLock;
public float jumpHeight;
public float grip;
public float maxVelocity;
public float maxAirVelocity;
private float curMaxVelocity;
public bool immobile;
public bool slowed;
private float curSpeed;
public float cameraX;
@ -37,6 +38,8 @@ public class thirdPersonController : MonoBehaviour {
private Rigidbody rigidbody;
public Collider curCollider;
@ -70,8 +73,8 @@ public class thirdPersonController : MonoBehaviour {
animator.SetBool ("Jump", false);
}
if (immobile)
curSpeed = 0.0f;
if (slowed)
curSpeed = 700.0f;
else
curSpeed = movementSpeed;
@ -99,10 +102,11 @@ public class thirdPersonController : MonoBehaviour {
}
animator.SetBool ("Grounded", grounded);
animator.SetFloat("Run speed",new Vector3 (rigidbody.velocity.x, 0.0f,rigidbody.velocity.z ).magnitude);
animator.SetFloat("Run speed",new Vector3 (rigidbody.velocity.x, 0.0f,rigidbody.velocity.z ).magnitude * Mathf.Sign(movementY));
rigidbody.AddForce (new Vector3 (0.0f, -9.81f,0.0f));
curCollider = null;
}
@ -126,6 +130,14 @@ public class thirdPersonController : MonoBehaviour {
private void applyMovement(){
movementX = Input.GetAxis (MOVEMENT_INPUT_X);
movementY = Input.GetAxis (MOVEMENT_INPUT_Y);
if (movementLock) {
movementX = 0;
if (movementY < 0 && this.name == "Player2")
movementY = 0;
if (movementY > 0 && this.name == "Player1")
movementY = 0;
}
Vector3 velocity = new Vector3 (movementX, 0.0f, movementY) * curSpeed * Time.deltaTime;
//Debug.Log (velocity);
@ -177,5 +189,15 @@ public class thirdPersonController : MonoBehaviour {
}
void OnCollisionStay(Collision col) {
if (col.transform.tag == "moveable")
curCollider = col.collider;
}
//void onCollisionExit(Collision col){
// if (curCollider == col.collider)
// curCollider = null;
//}
}

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


BIN
unity_Project/ProjectSettings/ProjectSettings.asset View File


+ 1
- 1
unity_Project/ProjectSettings/ProjectVersion.txt View File

@ -1,2 +1,2 @@
m_EditorVersion: 5.1.3f1
m_EditorVersion: 5.1.2f1
m_StandardAssetsVersion: 0

Loading…
Cancel
Save