Updated PlayerPrefab

Implemented Slide into player
Added CamFollow
This commit is contained in:
Melbyj1125 2021-11-01 12:15:17 -05:00
parent 45a2c5b473
commit 63e2318252
9 changed files with 354 additions and 218 deletions

View File

@ -11,6 +11,21 @@ GameObject:
- component: {fileID: 394725941300514827}
- component: {fileID: 3891196372269872751}
- component: {fileID: 1779614325098168083}
- component: {fileID: 5086810605069144388}
- component: {fileID: 3725107173017604129}
- component: {fileID: 508183713705064073}
- component: {fileID: 6646742430777996202}
- component: {fileID: 6946259593417347243}
- component: {fileID: 273103334658887749}
- component: {fileID: 1952443820573609623}
- component: {fileID: 4323471435859684389}
- component: {fileID: 3672942772524564832}
- component: {fileID: 2620970719070296463}
- component: {fileID: 2356773567935625033}
- component: {fileID: 2942875262947626129}
- component: {fileID: 8956701063868523892}
- component: {fileID: 3772338269032432186}
- component: {fileID: 5687943635225929219}
m_Layer: 0
m_Name: PlayerModel
m_TagString: Untagged
@ -81,73 +96,25 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &7188906082087890184
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7188906082087890177}
- component: {fileID: 7188906082087890180}
- component: {fileID: 7188906082087890183}
- component: {fileID: 7188906082087890185}
- component: {fileID: 6558661690282462800}
- component: {fileID: 2274833863450849408}
- component: {fileID: 471272923182148881}
- component: {fileID: 1292213096936070766}
- component: {fileID: 7623511089535041046}
- component: {fileID: 1602186932439279558}
- component: {fileID: 4910425103423673310}
- component: {fileID: 1122837021074491360}
- component: {fileID: 1006370620272136424}
- component: {fileID: 623466146960117777}
- component: {fileID: 1121632309457683679}
- component: {fileID: 7442108947324986527}
- component: {fileID: 3454731726544993114}
m_Layer: 3
m_Name: PlayerPrefab
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7188906082087890177
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1, y: 1.8, z: -0.2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 7188906082643956518}
- {fileID: 394725941300514827}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7188906082087890180
--- !u!114 &5086810605069144388
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: addc2e37ff81c1b4989ec34b6150b4f7, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &7188906082087890183
--- !u!114 &3725107173017604129
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5a5d879591af1084ab5d3a35fcd53086, type: 3}
@ -155,13 +122,13 @@ MonoBehaviour:
m_EditorClassIdentifier:
items: []
pStats: {fileID: 0}
--- !u!114 &7188906082087890185
--- !u!114 &508183713705064073
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 22ae0d31c49624d4fb9990f2f5f72fd9, type: 3}
@ -174,61 +141,13 @@ MonoBehaviour:
minAngle: -30
maxAngle: 45
sensitivity: 301
--- !u!143 &6558661690282462800
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0, z: 0}
--- !u!136 &2274833863450849408
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &471272923182148881
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &1292213096936070766
--- !u!114 &6646742430777996202
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
@ -239,13 +158,13 @@ MonoBehaviour:
PrefabHashGenerator: PlayerPrefab
AlwaysReplicateAsRoot: 0
DontDestroyWithOwner: 0
--- !u!114 &7623511089535041046
--- !u!114 &6946259593417347243
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
@ -287,104 +206,26 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &1602186932439279558
--- !u!114 &273103334658887749
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5162a84172831f4449df60b9ad0ce22f, type: 3}
m_Name:
m_EditorClassIdentifier:
controller: {fileID: 0}
--- !u!114 &4910425103423673310
--- !u!114 &1952443820573609623
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 980b3f40ede2d8a4c96587100cf71d02, type: 3}
m_Name:
m_EditorClassIdentifier:
moveDirection: {x: 0, y: 0, z: 0}
dashDistance: 10
dashStoppingSpeed: 0.1
--- !u!114 &1122837021074491360
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cee70ea30de57ec43a325c1ca6257526, type: 3}
m_Name:
m_EditorClassIdentifier:
maxGrappleDistance: 25
--- !u!114 &1006370620272136424
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f9b52b0ade3c44e47a3a4dc48c47ec1c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &623466146960117777
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0c0aad94b3b1332408ef8e7d07f3b321, type: 3}
m_Name:
m_EditorClassIdentifier:
leg: {fileID: 0}
--- !u!114 &1121632309457683679
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1a8c22589436d2449a89cf3a40b6d252, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &7442108947324986527
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aa419fd069f632e479eda138a7764362, type: 3}
m_Name:
m_EditorClassIdentifier:
playerCam: {fileID: 0}
--- !u!114 &3454731726544993114
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 535009eaa735a4c4e95c6fc270e32741, type: 3}
@ -399,6 +240,151 @@ MonoBehaviour:
wallBouncing: 3
cameraTransitionDuration: 1
wallGravityDownForce: 20
--- !u!114 &4323471435859684389
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 980b3f40ede2d8a4c96587100cf71d02, type: 3}
m_Name:
m_EditorClassIdentifier:
moveDirection: {x: 0, y: 0, z: 0}
dashDistance: 10
dashStoppingSpeed: 0.1
--- !u!114 &3672942772524564832
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cee70ea30de57ec43a325c1ca6257526, type: 3}
m_Name:
m_EditorClassIdentifier:
maxGrappleDistance: 25
--- !u!114 &2620970719070296463
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f9b52b0ade3c44e47a3a4dc48c47ec1c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &2356773567935625033
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0c0aad94b3b1332408ef8e7d07f3b321, type: 3}
m_Name:
m_EditorClassIdentifier:
leg: {fileID: 0}
--- !u!114 &2942875262947626129
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4814433541978696327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1a8c22589436d2449a89cf3a40b6d252, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!54 &8956701063868523892
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4814433541978696327}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!136 &3772338269032432186
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4814433541978696327}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5
m_Height: 1
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!143 &5687943635225929219
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4814433541978696327}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &7188906082087890184
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7188906082087890177}
m_Layer: 3
m_Name: PlayerPrefab
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7188906082087890177
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082087890184}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1, y: 1.8, z: -0.2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 7188906082643956518}
- {fileID: 394725941300514827}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7188906082643956521
GameObject:
m_ObjectHideFlags: 0
@ -410,6 +396,7 @@ GameObject:
- component: {fileID: 7188906082643956518}
- component: {fileID: 7188906082643956516}
- component: {fileID: 7188906082643956519}
- component: {fileID: 4875054560273456582}
m_Layer: 3
m_Name: PlayerCam
m_TagString: PlayerCam
@ -482,3 +469,16 @@ AudioListener:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082643956521}
m_Enabled: 1
--- !u!114 &4875054560273456582
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7188906082643956521}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 394466212a506df4da8f22e46bd4e333, type: 3}
m_Name:
m_EditorClassIdentifier:
player: {fileID: 4814433541978696327}

View File

@ -388,7 +388,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
itemOptPrefab: {fileID: 8447329698821624902, guid: 51a78c57dc85625428c8f1e6448d113f, type: 3}
moveScripts: []
--- !u!114 &526839288
MonoBehaviour:
m_ObjectHideFlags: 0
@ -526,10 +525,22 @@ PrefabInstance:
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3772338269032432186, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
propertyPath: m_Height
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4910425103423673310, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7061360697648900808, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
propertyPath: m_UseGravity
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7061360697648900808, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
propertyPath: m_IsKinematic
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7188906082087890177, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
propertyPath: m_RootOrder
value: 3
@ -586,6 +597,14 @@ PrefabInstance:
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8956701063868523892, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
propertyPath: m_UseGravity
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8956701063868523892, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
propertyPath: m_CollisionDetection
value: 3
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
--- !u!1 &591528209

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
//Mote: This should be refactored at some point
public class Slide : MonoBehaviour{
//this may be deprecated at some poiint later in development if we start ussing a rigid bod
public Camera playerCam;
private bool isSliding = false;
private CharacterController charController;
@ -11,10 +11,7 @@ public class Slide : MonoBehaviour{
private float orignalTraction;
private RaycastHit ray;
private Vector3 up;
// Start is called before the first frame update
void Start(){
}
private void Awake(){
charController = this.gameObject.GetComponentInParent<CharacterController>();
playerStats = this.gameObject.GetComponentInParent<PlayerStats>();

View File

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCam : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
private Vector3 rad;
void Start ()
{
rad = (transform.position - player.transform.position);
}
void Update ()
{
offset = transform.parent.forward * rad.magnitude;
transform.position = new Vector3((player.transform.position.x - offset.x),((player.transform.position.y - offset.y)+2),(player.transform.position.z - offset.z));
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 394466212a506df4da8f22e46bd4e333
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -13,7 +13,7 @@ public class PlayerInventory : MonoBehaviour
void Awake(){
pStats = GetComponent<PlayerStats>();
DontDestroyOnLoad(this.gameObject);
DontDestroyOnLoad(transform.parent.gameObject);
}

View File

@ -18,6 +18,9 @@ public class PlayerMovement : MonoBehaviour
private Vector3 moveX;
private Vector3 driftVel;
//Player prefab
private GameObject parentObj;
//Character Moving
private CharacterController moveController;
@ -67,6 +70,15 @@ public class PlayerMovement : MonoBehaviour
private Vector3 prevRot;
private Vector3 hitForce;
//Slide Variables
private bool isSliding = false;
private float originalTraction;
private RaycastHit ray;
private Vector3 up;
private bool qDown;
//Kick Variables
void Awake()
{
//Initialize Components
@ -74,13 +86,16 @@ public class PlayerMovement : MonoBehaviour
rB = GetComponent<Rigidbody>();
capCol = GetComponent<CapsuleCollider>();
pStats = GetComponent<PlayerStats>();
parentObj = transform.parent.gameObject;
//camera transform
cam = GetComponentInChildren<Camera>();
cam = parentObj.GetComponentInChildren<Camera>();
capCol.enabled = false;
//Wallrun
wallRun = gameObject.GetComponent<WallRun>();
up = this.gameObject.GetComponentInParent<Transform>().up;
}
void Start()
@ -137,8 +152,6 @@ public class PlayerMovement : MonoBehaviour
//Checks if player should respawn
Respawn();
}
@ -162,9 +175,13 @@ public class PlayerMovement : MonoBehaviour
Gravity();
driftVel = Vector3.Lerp(driftVel, vel, pStats.Traction * Time.deltaTime);
//Moving outside basic wasd
//Jump Function
Jump();
//Slide Function
Slide();
moveController.Move(driftVel);
}
@ -174,7 +191,7 @@ public class PlayerMovement : MonoBehaviour
public float PlayerSpeed()
{
//If nothing is pressed speed is 0
if (Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f)
if ((Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f) || isSliding)
{
pStats.CurVel = 0.0f;
return pStats.CurVel;
@ -215,7 +232,7 @@ public class PlayerMovement : MonoBehaviour
private void Jump()
{
//If space is pressed apply an upwards force to the player
if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum)
if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding)
{
AddImpact(transform.up, pStats.JumpPow);
curJumpNum++;
@ -261,14 +278,21 @@ public class PlayerMovement : MonoBehaviour
private void Rotation()
{
Vector3 lastCamPos = new Vector3(0,0,0);
Vector3 rotOffset = transform.localEulerAngles;
if(moveController.enabled){
transform.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
cam.transform.localEulerAngles = camRotation;
}
/*
else{
cam.transform.localEulerAngles = cam.transform.localEulerAngles - rotOffset;
}
*/
}
@ -368,7 +392,7 @@ public class PlayerMovement : MonoBehaviour
//When to begin the ragdoll timer
private float RagdollTimer(){
if(beginRagTimer == false){
beginRagTimer = Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1f);
beginRagTimer = Physics.Raycast(transform.position, -Vector3.up, distToGround + 1f);
}
else if(ragTime <= 0){
@ -383,6 +407,57 @@ public class PlayerMovement : MonoBehaviour
return ragTime;
}
//Slide Function
private void Slide(){
if (Input.GetKey(KeyCode.Q)){
qDown = true;
if (isSliding == false){
originalTraction = pStats.Traction;
this.gameObject.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x - 90, this.transform.eulerAngles.y, this.transform.eulerAngles.z);
isSliding = true;
moveController.height = 1.0f;
pStats.Traction = 0.01f;
}
pStats.Traction += .02f;
}
else{
qDown = false;
}
//NOTE: potentialy change this to only allow player back up if there is nothing above them
if (qDown == false && isSliding == true) {
//if nothing is above the object, stop slidding
if (Physics.Raycast(this.gameObject.transform.position, up, out ray, 5f) == false)
{
this.gameObject.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x + 90, this.transform.eulerAngles.y, this.transform.eulerAngles.z);
isSliding = false;
moveController.height = 2.0f;
pStats.Traction = originalTraction;
}
else{
Debug.Log("Object above you");
}
}
//if button is not held down, and still slidding (if they let go but something was above them) check to see if something is still above them, if not
else if (Input.GetKey(KeyCode.Q) == false && isSliding==true){
//if nothing is above the object, stop slidding
if (Physics.Raycast(this.gameObject.transform.position, up, out ray, 5f) == false)
{
this.gameObject.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x - 90, this.transform.eulerAngles.y, this.transform.eulerAngles.z);
isSliding = false;
moveController.height = 2.0f;
pStats.Traction = originalTraction;
}
else
{
Debug.Log("Object above you");
}
}
}
}

View File

@ -26,7 +26,7 @@ public class PlayerStats : MonoBehaviour
set{ curVel = value; }
}
//Player Jump power
//Player Acceleration
private float acc = 0.1f;
public float Acc{
get{ return acc; }
@ -62,7 +62,7 @@ public class PlayerStats : MonoBehaviour
}
//Player Recovery Time When Knocked Down
private float recovTime = 5;
private float recovTime = 3.0f;
public float RecovTime{
get{ return recovTime; }
set{ recovTime = value; }
@ -112,7 +112,7 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Dash
private bool hasDash = false;
private bool hasDash;
public bool HasDash{
get{ return hasDash; }
set{ hasDash = value; }
@ -124,12 +124,21 @@ public class PlayerStats : MonoBehaviour
set{ playerPoints = value; }
}
// void Update(){
// VariableValidation();
// }
void Update(){
VariableValidation();
}
// void VariableValidation(){
// Debug.Assert((playerPoints != null && playerPoints > 0), "Not valid value");
// }
void VariableValidation(){
Debug.Assert((maxVel >= 0), "maxVel cannot be below zero");
Debug.Assert((minVel >= 0), "minVel cannot be below zero");
Debug.Assert((curVel >= 0), "curVel cannot be below zero");
Debug.Assert((jumpPow >= 0), "jumpPow cannot be below zero");
Debug.Assert((jumpNum >= 2), "jumpNum cannot be below zero");
Debug.Assert((traction >= 0), "traction cannot be below zero");
//Debug.Assert((kickPow >= 0), "Playerpoints cannot be below zero");
Debug.Assert((recovTime >= 0), "recovTime cannot be below zero");
Debug.Assert((playerGrav >= 0), "playerGrav cannot be below zero");
Debug.Assert((playerPoints >= 0), "Playerpoints cannot be below zero");
}
}

View File

@ -6,6 +6,7 @@ using UnityEngine.SceneManagement;
public class InvSceneSettings : MonoBehaviour
{
GameObject pPar;
GameObject player1;
PlayerInventory pInv;
public GameObject itemOptPrefab;
@ -18,12 +19,13 @@ public class InvSceneSettings : MonoBehaviour
// Start is called before the first frame update
void Awake(){
player1 = GameObject.Find("PlayerPrefab");
pPar = GameObject.Find("PlayerPrefab");
player1 = pPar.transform.Find("PlayerModel").gameObject;
pStats = player1.GetComponent<PlayerStats>();
pointText = GameObject.Find("PlayerPoints").GetComponentInChildren<Text>();
pInv = player1.GetComponent<PlayerInventory>();
player1.GetComponent<PlayerMovement>().enabled = false;
player1.transform.Find("PlayerCam").gameObject.SetActive(false);
pPar.transform.Find("PlayerCam").gameObject.SetActive(false);
invMan = GetComponent<InventoryManager>();
}
@ -107,7 +109,7 @@ public class InvSceneSettings : MonoBehaviour
public void nextScene(){
player1.GetComponent<PlayerMovement>().enabled = true;
player1.GetComponent<CapsuleCollider>().enabled = false;
player1.transform.GetChild(0).gameObject.SetActive(true);
pPar.transform.GetChild(0).gameObject.SetActive(true);
SceneManager.LoadScene (SceneManager.GetActiveScene().buildIndex + 1);
}