Browse Source

Bug fixes, updating mechanics.

master
Joshua Reason 9 years ago
parent
commit
0aff26e8a1
19 changed files with 335 additions and 29 deletions
  1. BIN
      unity_Project/Assets/0bjects/Materials/rust.mat
  2. +8
    -0
      unity_Project/Assets/0bjects/Materials/rust.mat.meta
  3. +2
    -2
      unity_Project/Assets/0bjects/Textures/Character_texture_2048_WiP_01_FLAT.jpg.meta
  4. BIN
      unity_Project/Assets/Materials/Player1.mat
  5. BIN
      unity_Project/Assets/Materials/Purple.mat
  6. +45
    -2
      unity_Project/Assets/Scripts/magnetGun.cs
  7. +85
    -0
      unity_Project/Assets/Scripts/magnetGun2.cs
  8. +12
    -0
      unity_Project/Assets/Scripts/magnetGun2.cs.meta
  9. +62
    -0
      unity_Project/Assets/Scripts/playerFollow.cs
  10. +12
    -0
      unity_Project/Assets/Scripts/playerFollow.cs.meta
  11. +42
    -4
      unity_Project/Assets/Scripts/sceneController.cs
  12. +66
    -20
      unity_Project/Assets/Scripts/thirdPersonController.cs
  13. BIN
      unity_Project/Assets/Standard Assets/Effects/ToonShading/Materials/ToonLitOutline.mat
  14. BIN
      unity_Project/Assets/_Scenes/MainLevel.unity
  15. BIN
      unity_Project/Assets/_Scenes/ScafoldingTest.unity
  16. BIN
      unity_Project/ProjectSettings/EditorBuildSettings.asset
  17. BIN
      unity_Project/ProjectSettings/InputManager.asset
  18. BIN
      unity_Project/ProjectSettings/ProjectSettings.asset
  19. +1
    -1
      unity_Project/ProjectSettings/ProjectVersion.txt

BIN
unity_Project/Assets/0bjects/Materials/rust.mat View File


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

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 30f266bafdd7a8d4a9238d277b5b2d95
timeCreated: 1441173592
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 2
- 2
unity_Project/Assets/0bjects/Textures/Character_texture_2048_WiP_01_FLAT.jpg.meta View File

@ -32,7 +32,7 @@ TextureImporter:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
wrapMode: 1
nPOTScale: 1
lightmap: 0
rGBM: 0
@ -45,7 +45,7 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
textureType: 0
buildTargetSettings: []
spriteSheet:
sprites: []

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


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


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

@ -27,9 +27,11 @@ public class magnetGun : MonoBehaviour {
public float maxPullSpeed = 30;
public float rotateSpeed;
public float minDistance = 3.0f;
public float impulsePower = 50.0f;
private float maxWalkSpeed;
private Renderer lastTargetRenderer;
private Color lastTargetColour;
// Use this for initialization
void Start () {
if (topScreen)
@ -56,9 +58,14 @@ public class magnetGun : MonoBehaviour {
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;
}
}
}
updateColors (target);
if (triggerL > 0) {
@ -71,6 +78,7 @@ public class magnetGun : MonoBehaviour {
dropItem(GravityTarget);
}
impulsePush (target);
moveItem (GravityTarget);
pullItem (triggerR);
rotateInput (GravityTarget);
@ -86,7 +94,9 @@ public class magnetGun : MonoBehaviour {
RaycastHit hit;
//Vector3 rayDirection = camera.transform.rotation * Vector3.forward;
Ray ray = camera.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2 + (Screen.height/6 * playerScreen), 0));
//Ray ray = camera.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2 + (Screen.height/6 * playerScreen), 0));
Ray ray = camera.ScreenPointToRay(crossHair.transform.position);
Debug.DrawRay (ray.origin, ray.direction*magnetRange, Color.green);
@ -94,6 +104,7 @@ public class magnetGun : MonoBehaviour {
if (hit.collider.tag == "moveable"){
Debug.DrawRay (ray.origin,ray.direction*magnetRange, Color.red);
rayHitPoint = hit.point;
}
@ -107,6 +118,9 @@ public class magnetGun : MonoBehaviour {
item.attachedRigidbody.useGravity = false;
item.attachedRigidbody.drag = 3.0f;
item.attachedRigidbody.constraints = RigidbodyConstraints.FreezeRotation;
//camera.transform.LookAt(item.transform.position);
//playerController.cameraX = camera.transform.eulerAngles.x;
//playerController.cameraY = camera.transform.eulerAngles.y;
gravityWell.transform.position = rayHitPoint;
GravityTarget = item;
targetOffset = GravityTarget.transform.position - rayHitPoint + (Vector3.up * 0.05f);
@ -123,6 +137,16 @@ public class magnetGun : MonoBehaviour {
}
}
private void impulsePush (Collider item){
if (item != null) {
if (item.tag == "moveable" && Input.GetButtonDown("Quick Push")){
Vector3 direction = (transform.position - item.transform.position).normalized;
item.attachedRigidbody.AddForce(direction * impulsePower * maxPullSpeed,ForceMode.Impulse);
}
}
}
private void moveItem(Collider item){
if (item != null) {
float step = objectSpeed * Time.deltaTime;
@ -206,5 +230,24 @@ public class magnetGun : MonoBehaviour {
}
}
public void updateColors(Collider target){
if (target != null && target.tag == "moveable") {
lastTargetRenderer = target.GetComponent<Renderer> ();
if (lastTargetRenderer.material.color != Color.white) {
lastTargetColour = lastTargetRenderer.material.color;
lastTargetRenderer.material.color = Color.white;
}
} else {
if (lastTargetRenderer != null)
lastTargetRenderer.material.color = lastTargetColour;
}
}
}

+ 85
- 0
unity_Project/Assets/Scripts/magnetGun2.cs View File

@ -0,0 +1,85 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class magnetGun2 : MonoBehaviour {
public Camera camera;
public GameObject crossHair;
public GameObject gravityWell;
public thirdPersonController playerController;
public float magnetMaxRange;
public float magnetMinRange;
private Collider gravityTarget;
// Use this for initialization
void Start () {
magnetMinRange += playerController.cameraDistance;
magnetMaxRange += playerController.cameraDistance;
}
// Update is called once per frame
void Update () {
RaycastHit target = testItem ();
if (gravityTarget != null)
pickUpItem (target);
}
//test to see if player can move item
private RaycastHit testItem(){
RaycastHit hit;
//resets cross hair to white
crossHair.GetComponent<RawImage> ().color = Color.white;
//cast ray from camera through the crosshair on screen
Ray ray = camera.ScreenPointToRay (crossHair.transform.position);
Debug.DrawRay (ray.origin, ray.direction*magnetMaxRange, Color.green);
// if player can pickup object turn crosshair red
// if object is close enougth to move with it turn blue;
if (Physics.Raycast (ray, out hit, magnetMaxRange)) {
if (hit.collider.tag == "moveable"){
gravityTarget = hit.collider;
Debug.DrawRay (ray.origin,ray.direction*magnetMaxRange, Color.red);
crossHair.GetComponent<RawImage>().color = Color.red;
if (Vector3.Distance (hit.point, camera.transform.position) <= magnetMinRange) {
crossHair.GetComponent<RawImage>().color = Color.blue;
}//end blue
}//end red
}//end raycast
return hit;
}// end testItem()
private void pickUpItem(RaycastHit hit){
Collider item = hit.collider;
//prepares item to be lifted
item.attachedRigidbody.useGravity = false;
item.attachedRigidbody.drag = 3.0f;
item.attachedRigidbody.constraints = RigidbodyConstraints.FreezeRotation;
gravityWell.transform.position = item.transform.position;
transform.LookAt (gravityWell.transform.position, Vector3.up);
}
}

+ 12
- 0
unity_Project/Assets/Scripts/magnetGun2.cs.meta View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f910766fbbe259c498dcedc745d3c08b
timeCreated: 1441338166
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 62
- 0
unity_Project/Assets/Scripts/playerFollow.cs View File

@ -0,0 +1,62 @@
using UnityEngine;
using System.Collections;
public class playerFollow : MonoBehaviour {
public GameObject target;
public float minDistance = 4;
public bool active;
private bool follow = false;
private Rigidbody rigidbody;
private thirdPersonController playerController;
// Use this for initialization
void Start () {
rigidbody = GetComponent<Rigidbody> ();
playerController = GetComponent<thirdPersonController> ();
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown ("follow")&& !active)
follow = !follow;
if (Input.GetButtonDown ("playerSwap")) {
active = !active;
follow = false;
}
}
void FixedUpdate(){
if (follow)
followPlayer ();
}
private void followPlayer(){
Vector3 lookAtTarget = target.transform.position;
lookAtTarget.y = transform.position.y;
transform.LookAt (lookAtTarget);
if (minDistance < Vector3.Distance (target.transform.position, transform.position)) {
Vector3 direction = target.transform.position;
direction.y = transform.position.y;
direction -= transform.position;
direction.Normalize ();
rigidbody.AddForce (direction * playerController.movementSpeed * Time.deltaTime);
}
}
}

+ 12
- 0
unity_Project/Assets/Scripts/playerFollow.cs.meta View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1b5095c83499af44ba3770f8f0ecd16f
timeCreated: 1441869920
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

@ -8,6 +8,8 @@ public class sceneController : MonoBehaviour {
public GameObject player2;
public Camera cameraPlayer1;
public Camera cameraPlayer2;
public GameObject crossHairPlayer1;
public GameObject crossHairPlayer2;
public GameObject playerPointer;
public float screenAnimationTime;
@ -15,14 +17,37 @@ public class sceneController : MonoBehaviour {
private thirdPersonController movementP1;
private thirdPersonController movementP2;
private bool activeP1 = true;
private bool activeP2 = false;
private string playerSwapInput = "playerSwap";
// Use this for initialization
void Start () {
//Physics.IgnoreCollision(player1.GetComponent<Collider>(), player2.GetComponent<Collider>(),true);
movementP1 = player1.GetComponent<thirdPersonController> ();
movementP2 = player2.GetComponent<thirdPersonController> ();
movementP2.enabled = false;
movementP2.active = false;
crossHairPlayer2.SetActive (false);
Component[] p1Colliders = player1.GetComponentsInChildren<Collider> ();
Component[] p2Colliders = player2.GetComponentsInChildren<Collider> ();
foreach (Collider p1Col in p1Colliders){
foreach (Collider p2Col in p2Colliders){
Physics.IgnoreCollision(p1Col, p2Col);
}
}
}
@ -39,18 +64,29 @@ public class sceneController : MonoBehaviour {
if (Input.GetButtonDown(playerSwapInput)) {
Debug.Log("swappy Swap");
movementP1.enabled = !movementP1.enabled;
movementP2.enabled = !movementP2.enabled;
activeP1 = !activeP1;
activeP2 = !activeP2;
if (movementP1.enabled){
if (activeP1){
newCamera = cameraPlayer1;
oldCamera = cameraPlayer2;
crossHairPlayer1.SetActive(true);
crossHairPlayer2.SetActive(false);
}else{
newCamera = cameraPlayer2;
oldCamera = cameraPlayer1;
crossHairPlayer1.SetActive(false);
crossHairPlayer2.SetActive(true);
}
movementP1.active = activeP1;
movementP2.active = activeP2;
newCamera.depth = 0;
oldCamera.depth = 1;
@ -156,4 +192,6 @@ public class sceneController : MonoBehaviour {
}
}

+ 66
- 20
unity_Project/Assets/Scripts/thirdPersonController.cs View File

@ -15,56 +15,61 @@ public class thirdPersonController : MonoBehaviour {
public float cameraSpeedX = 250.0f;
public float cameraSpeedY = 120.0f;
public float cameraDistance = 10.0f;
public bool active = true;
public float movementSpeed;
public float jumpHeight;
public float grip;
private float cameraX;
private float cameraY;
public float cameraX;
public float cameraY;
private float movementX;
private float movementY;
private bool grounded;
private Rigidbody rigidbody;
// Use this for initialization
void Start () {
rigidbody = GetComponent<Rigidbody> ();
cameraX = camera.transform.eulerAngles.x;
cameraY = camera.transform.eulerAngles.y;
}
void FixedUpdate(){
if (Physics.Raycast (transform.position, -Vector3.up, 1.3f)) {
grounded = true;
} else {
grounded = false;
}
if (active) {
movementX = Input.GetAxis (MOVEMENT_INPUT_X);
movementY = Input.GetAxis (MOVEMENT_INPUT_Y);
Vector3 velocity = new Vector3 (movementX, 0.0f, movementY)* movementSpeed * Time.deltaTime;
//Debug.Log (velocity);
velocity = Quaternion.Euler (0.0f,camera.transform.rotation.eulerAngles.y, 0.0f) * velocity;
applyMovement();
GetComponent<Rigidbody>().AddForce (velocity);
transform.rotation = Quaternion.Euler (new Vector3 (0.0f, camera.transform.rotation.eulerAngles.y, 0.0f));
//if (velocity != Vector3.zero)
transform.rotation = Quaternion.Euler(new Vector3 (0.0f, camera.transform.rotation.eulerAngles.y, 0.0f));
applyJump(jumpHeight);
applyGrip();
if (Physics.Raycast (transform.position, -Vector3.up, 1.3f)) {
//print ("Raycast succeeded");
if (Input.GetButtonDown (JUMP_INPUT)) {
GetComponent<Rigidbody>().AddRelativeForce (0, jumpHeight, 0);
}
}
}
// Update is called once per frame
void LateUpdate () {
cameraX += Input.GetAxis(CAMERA_INPUT_X) * cameraSpeedX * 0.02f;
cameraY += Input.GetAxis(CAMERA_INPUT_Y) * cameraSpeedY * 0.02f;
if (active) {
cameraX += Input.GetAxis (CAMERA_INPUT_X) * cameraSpeedX * 0.02f;
cameraY += Input.GetAxis (CAMERA_INPUT_Y) * cameraSpeedY * 0.02f;
}
Quaternion cameraRotation = Quaternion.Euler (cameraY, cameraX, 0.0f);
Vector3 cameraPosition = cameraRotation * new Vector3(0.0f, 0.0f, -cameraDistance) + cameraCentre.transform.position;
@ -73,4 +78,45 @@ public class thirdPersonController : MonoBehaviour {
}
private void applyMovement(){
movementX = Input.GetAxis (MOVEMENT_INPUT_X);
movementY = Input.GetAxis (MOVEMENT_INPUT_Y);
Vector3 velocity = new Vector3 (movementX, 0.0f, movementY) * movementSpeed * Time.deltaTime;
//Debug.Log (velocity);
velocity = Quaternion.Euler (0.0f, camera.transform.rotation.eulerAngles.y, 0.0f) * velocity;
rigidbody.AddForce (velocity);
}
private void applyJump(float power){
if (grounded) {
if (Input.GetButtonDown (JUMP_INPUT)) {
rigidbody.AddRelativeForce (0, power, 0);
}
}
}
private void applyGrip(){
float localVelX = transform.InverseTransformDirection (rigidbody.velocity).x;
float localVelZ = transform.InverseTransformDirection (rigidbody.velocity).z;
//Debug.Log ("velocity.y: " + localVelZ);
if (grounded && Mathf.Abs(movementX) < 0.8f ) {
rigidbody.AddForce(transform.right * -localVelX * grip);
if (movementY < 0.5f && localVelZ > 1.0f){
rigidbody.AddForce(-transform.forward * grip * localVelZ );
}
}
}
}

BIN
unity_Project/Assets/Standard Assets/Effects/ToonShading/Materials/ToonLitOutline.mat View File


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


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


BIN
unity_Project/ProjectSettings/EditorBuildSettings.asset View File


BIN
unity_Project/ProjectSettings/InputManager.asset 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