mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-04-26 02:00:54 -05:00
grapple still doesn't work fixed some other values with prefabs
This commit is contained in:
parent
610d8b832e
commit
946e2146a3
BIN
Assets/New Terrain.asset
Normal file
BIN
Assets/New Terrain.asset
Normal file
Binary file not shown.
8
Assets/New Terrain.asset.meta
Normal file
8
Assets/New Terrain.asset.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d879c807dc45e714892ef692f67c4254
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 15600000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -520,6 +520,82 @@ MeshFilter:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 478416584}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &581642405
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 581642408}
|
||||
- component: {fileID: 581642407}
|
||||
- component: {fileID: 581642406}
|
||||
m_Layer: 0
|
||||
m_Name: Terrain
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 4294967295
|
||||
m_IsActive: 1
|
||||
--- !u!154 &581642406
|
||||
TerrainCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 581642405}
|
||||
m_Material: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_TerrainData: {fileID: 15600000, guid: d879c807dc45e714892ef692f67c4254, type: 2}
|
||||
m_EnableTreeColliders: 1
|
||||
--- !u!218 &581642407
|
||||
Terrain:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 581642405}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 6
|
||||
m_TerrainData: {fileID: 15600000, guid: d879c807dc45e714892ef692f67c4254, type: 2}
|
||||
m_TreeDistance: 5000
|
||||
m_TreeBillboardDistance: 50
|
||||
m_TreeCrossFadeLength: 5
|
||||
m_TreeMaximumFullLODCount: 50
|
||||
m_DetailObjectDistance: 80
|
||||
m_DetailObjectDensity: 1
|
||||
m_HeightmapPixelError: 5
|
||||
m_SplatMapDistance: 1000
|
||||
m_HeightmapMaximumLOD: 0
|
||||
m_ShadowCastingMode: 2
|
||||
m_DrawHeightmap: 1
|
||||
m_DrawInstanced: 0
|
||||
m_DrawTreesAndFoliage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_MaterialTemplate: {fileID: 10652, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_BakeLightProbesForTrees: 1
|
||||
m_PreserveTreePrototypeLayers: 0
|
||||
m_DeringLightProbesForTrees: 1
|
||||
m_ScaleInLightmap: 0.0256
|
||||
m_LightmapParameters: {fileID: 15203, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_GroupingID: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_AllowAutoConnect: 1
|
||||
--- !u!4 &581642408
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 581642405}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 8
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &724425600
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1078,6 +1154,10 @@ PrefabInstance:
|
|||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 471283137481508403, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
|
||||
propertyPath: propelPower
|
||||
value: 50
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5633209979457551608, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: DebugPlayerPrefab
|
||||
|
|
@ -1126,6 +1206,14 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7058615058147771192, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
|
||||
propertyPath: m_IsKinematic
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7058615058147771192, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
|
||||
propertyPath: m_CollisionDetection
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
|
||||
--- !u!1 &1257935739
|
||||
|
|
@ -1407,8 +1495,8 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1405946429}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -1.5, y: 23.9, z: 10.3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalPosition: {x: -9.8, y: 18.3, z: 10.3}
|
||||
m_LocalScale: {x: 10, y: 10, z: 10}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public class Bumper : MonoBehaviour {
|
|||
// Is called whenever something collides with the bumper
|
||||
void OnTriggerEnter(Collider objectHit) {
|
||||
if (objectHit.tag == "Player") {//Checks if the other object is the player
|
||||
dPlayerMovement playerMovement = objectHit.GetComponent<dPlayerMovement>();
|
||||
PlayerMovement playerMovement = objectHit.GetComponent<PlayerMovement>();
|
||||
|
||||
float DirBumpX = playerMovement.driftVel.x * -1;//Inverts the Player Velocity x
|
||||
float DirBumpY = .1f;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using UnityEngine;
|
|||
|
||||
public class dGrapplingHook : NetworkBehaviour
|
||||
{
|
||||
public float maxGrappleDistance = 25;
|
||||
public float maxGrappleDistance = 25;
|
||||
|
||||
public bool isGrappled;
|
||||
private int hookPointIndex;
|
||||
|
|
@ -16,14 +16,13 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
private CharacterController movementController;
|
||||
private dPlayerMovement playerMovement;
|
||||
private PlayerStats pStats;
|
||||
private Vector3 hookLerp;
|
||||
public float ropeLength;
|
||||
[SerializeField] private float ropeLength;
|
||||
private float climbRate = 5;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
isGrappled = false;
|
||||
isGrappled = false;
|
||||
hookPoints = GameObject.FindGameObjectsWithTag("HookPoint");
|
||||
movementController = gameObject.GetComponent<CharacterController>();
|
||||
playerMovement = gameObject.GetComponent<dPlayerMovement>();
|
||||
|
|
@ -35,7 +34,6 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
{
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
//if E or left face gamepad button is pressed is slightly pressed
|
||||
if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
|
||||
{
|
||||
if (!isGrappled) //If we are not grappling
|
||||
|
|
@ -47,7 +45,7 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
ropeLength = Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) + 0.5f;
|
||||
isGrappled = true; //toggle grappling state
|
||||
}
|
||||
}
|
||||
}
|
||||
else //Else we are grappling
|
||||
{
|
||||
//physics tear down?
|
||||
|
|
@ -62,7 +60,6 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
{
|
||||
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
|
||||
|
||||
//if left shift or left bumper held down
|
||||
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.JoystickButton4)) //Extend hook
|
||||
{
|
||||
ropeLength += climbRate * Time.deltaTime;
|
||||
|
|
@ -82,24 +79,23 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
//Do grappling physics based on hookPoint
|
||||
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength)
|
||||
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength )
|
||||
{
|
||||
movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * Time.deltaTime);
|
||||
//Character controller move?
|
||||
//movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength * 10 *Time.deltaTime);
|
||||
//Lerp? or another smoother way? Better physics? Wait until refinement to deal with
|
||||
//Impact Based
|
||||
Debug.Log("y");
|
||||
playerMovement.g = 2;
|
||||
movementController.Move((hookPoint.transform.position - gameObject.transform.position) * Time.deltaTime);
|
||||
|
||||
}
|
||||
}
|
||||
if(playerMovement.GetJumpPressed()){
|
||||
isGrappled = false;
|
||||
}
|
||||
if(playerMovement.GetJumpPressed()) isGrappled = false;
|
||||
}
|
||||
|
||||
int FindHookPoint()
|
||||
{
|
||||
float least = maxGrappleDistance;
|
||||
int index = -1;
|
||||
for (int i = 0; i < hookPoints.Length; i++)
|
||||
for(int i = 0; i<hookPoints.Length; i++)
|
||||
{
|
||||
distance = Vector3.Distance(gameObject.transform.position, hookPoints[i].transform.position);
|
||||
if (distance <= least)
|
||||
|
|
@ -109,4 +105,60 @@ public class dGrapplingHook : NetworkBehaviour
|
|||
}
|
||||
return index;
|
||||
}
|
||||
///////////Hookshot Concept
|
||||
// public float maxGrappleDistance = 25;
|
||||
|
||||
// public bool isGrappled;
|
||||
// private Vector3 hookPoint;
|
||||
// private float distance;
|
||||
// public float propelPower = 100;
|
||||
|
||||
// private CharacterController movementController;
|
||||
// private dPlayerMovement playerMovement;
|
||||
// private PlayerStats pStats;
|
||||
// private Camera cam;
|
||||
// private Vector3 forwardHookLerp;
|
||||
// private Vector3 upwardsHookLerp;
|
||||
|
||||
// // Start is called before the first frame update
|
||||
// void Start()
|
||||
// {
|
||||
// isGrappled = false;
|
||||
// movementController = gameObject.GetComponent<CharacterController>();
|
||||
// playerMovement = gameObject.GetComponent<dPlayerMovement>();
|
||||
// pStats = gameObject.GetComponent<PlayerStats>();
|
||||
// cam = playerMovement.cam;
|
||||
// }
|
||||
|
||||
// private void FixedUpdate()
|
||||
// {
|
||||
// getGrapplePoint();
|
||||
// //Debug.Log((hookPoint.transform.position - transform.position).normalized);
|
||||
// if (isGrappled && !Input.GetKeyDown(KeyCode.E))
|
||||
// {
|
||||
// //playerMovement.AddImpact((hookPoint - transform.position), propelPower);
|
||||
// forwardHookLerp = Vector3.Lerp(forwardHookLerp, transform.forward * 50, .03f);
|
||||
// movementController.Move(forwardHookLerp * Time.deltaTime);
|
||||
|
||||
// upwardsHookLerp = Vector3.Lerp(upwardsHookLerp, (hookPoint - transform.position).normalized * Vector3.Distance(transform.position, hookPoint) * propelPower, .03f);
|
||||
// movementController.Move(upwardsHookLerp * Time.deltaTime);
|
||||
// isGrappled = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void getGrapplePoint(){
|
||||
// //if E or left face gamepad button is pressed is slightly pressed
|
||||
// if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
|
||||
// {
|
||||
// if (!isGrappled) //If we are not grappling
|
||||
// {
|
||||
// if(Physics.Raycast(cam.transform.position, cam.transform.forward, out RaycastHit raycastHit)){
|
||||
// if(raycastHit.collider.gameObject.transform.tag == "HookPoint"){
|
||||
// isGrappled = true;
|
||||
// hookPoint = new Vector3 (raycastHit.point.x,raycastHit.point.y,raycastHit.point.z);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class dPlayerMovement : NetworkBehaviour
|
|||
float curCoyJumpTimer; // current Coyote Jump time
|
||||
public float lowJumpMultiplier; // Short jump multiplier
|
||||
public float fallMultiplier; // High Jump Multiplier
|
||||
private float g = 0; // the y velocity
|
||||
public float g = 0; // the y velocity
|
||||
|
||||
//Glide Values
|
||||
bool tempSet = false;
|
||||
|
|
@ -99,7 +99,7 @@ public class dPlayerMovement : NetworkBehaviour
|
|||
moveController = GetComponent<CharacterController>(); // Character Controller
|
||||
rB = GetComponent<Rigidbody>(); //Rigid Body
|
||||
capCol = GetComponent<CapsuleCollider>(); // Capsule Collider
|
||||
capCol.enabled = false;
|
||||
capCol.enabled = true;
|
||||
parentObj = transform.parent.gameObject;
|
||||
animator = GetComponent<Animator>();
|
||||
|
||||
|
|
@ -296,6 +296,8 @@ public class dPlayerMovement : NetworkBehaviour
|
|||
//if jump is being held coyote timer is zero
|
||||
if(jumpHeld) curCoyJumpTimer = 0;
|
||||
|
||||
if(grapple.isGrappled && curJumpNum == 2) curJumpNum = 1;
|
||||
|
||||
//If space/south face gamepad button isn't being pressed then jump is false
|
||||
if (Input.GetAxis("Jump") == 0){
|
||||
jumpHeld = false;
|
||||
|
|
@ -438,10 +440,9 @@ public class dPlayerMovement : NetworkBehaviour
|
|||
}
|
||||
|
||||
//apply gravity if not grounded and coyote timer is less than 0
|
||||
if((isGrounded == false && curCoyJumpTimer <= 0) || (!grapple.isGrappled && isGrounded == false)){
|
||||
if(isGrounded == false && curCoyJumpTimer <= 0){
|
||||
g -= grav * Time.deltaTime;
|
||||
}
|
||||
|
||||
//else don't apply gravity
|
||||
else{
|
||||
g = 0;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ using UnityEngine;
|
|||
|
||||
public class GrapplingHook : NetworkBehaviour
|
||||
{
|
||||
public float maxGrappleDistance = 25;
|
||||
public float maxGrappleDistance = 25;
|
||||
|
||||
private bool isGrappled;
|
||||
public bool isGrappled;
|
||||
private int hookPointIndex;
|
||||
private GameObject hookPoint;
|
||||
private GameObject[] hookPoints;
|
||||
|
|
@ -16,7 +16,7 @@ public class GrapplingHook : NetworkBehaviour
|
|||
private CharacterController movementController;
|
||||
private PlayerMovement playerMovement;
|
||||
private PlayerStats pStats;
|
||||
private float ropeLength;
|
||||
[SerializeField] private float ropeLength;
|
||||
private float climbRate = 5;
|
||||
|
||||
// Start is called before the first frame update
|
||||
|
|
@ -56,6 +56,7 @@ public class GrapplingHook : NetworkBehaviour
|
|||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!IsLocalPlayer) { return; }
|
||||
if (isGrappled)
|
||||
{
|
||||
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
|
||||
|
|
@ -79,15 +80,16 @@ public class GrapplingHook : NetworkBehaviour
|
|||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
//Do grappling physics based on hookPoint
|
||||
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength)
|
||||
if (Vector3.Distance(gameObject.transform.position, hookPoint.transform.position) > ropeLength )
|
||||
{
|
||||
//Impact Based
|
||||
playerMovement.AddImpact((hookPoint.transform.position - gameObject.transform.position), pStats.PlayerGrav);
|
||||
//Character controller move?
|
||||
//movementController.Move((hookPoint.transform.position - gameObject.transform.position).normalized * ropeLength*Time.deltaTime);
|
||||
//Lerp? or another smoother way? Better physics? Wait until refinement to deal with
|
||||
Debug.Log("y");
|
||||
playerMovement.g = 2;
|
||||
movementController.Move((hookPoint.transform.position - gameObject.transform.position) * Time.deltaTime);
|
||||
|
||||
}
|
||||
}
|
||||
if(playerMovement.GetJumpPressed()) isGrappled = false;
|
||||
}
|
||||
|
||||
int FindHookPoint()
|
||||
|
|
@ -104,4 +106,60 @@ public class GrapplingHook : NetworkBehaviour
|
|||
}
|
||||
return index;
|
||||
}
|
||||
///////////Hookshot Concept
|
||||
// public float maxGrappleDistance = 25;
|
||||
|
||||
// public bool isGrappled;
|
||||
// private Vector3 hookPoint;
|
||||
// private float distance;
|
||||
// public float propelPower = 100;
|
||||
|
||||
// private CharacterController movementController;
|
||||
// private dPlayerMovement playerMovement;
|
||||
// private PlayerStats pStats;
|
||||
// private Camera cam;
|
||||
// private Vector3 forwardHookLerp;
|
||||
// private Vector3 upwardsHookLerp;
|
||||
|
||||
// // Start is called before the first frame update
|
||||
// void Start()
|
||||
// {
|
||||
// isGrappled = false;
|
||||
// movementController = gameObject.GetComponent<CharacterController>();
|
||||
// playerMovement = gameObject.GetComponent<dPlayerMovement>();
|
||||
// pStats = gameObject.GetComponent<PlayerStats>();
|
||||
// cam = playerMovement.cam;
|
||||
// }
|
||||
|
||||
// private void FixedUpdate()
|
||||
// {
|
||||
// getGrapplePoint();
|
||||
// //Debug.Log((hookPoint.transform.position - transform.position).normalized);
|
||||
// if (isGrappled && !Input.GetKeyDown(KeyCode.E))
|
||||
// {
|
||||
// //playerMovement.AddImpact((hookPoint - transform.position), propelPower);
|
||||
// forwardHookLerp = Vector3.Lerp(forwardHookLerp, transform.forward * 50, .03f);
|
||||
// movementController.Move(forwardHookLerp * Time.deltaTime);
|
||||
|
||||
// upwardsHookLerp = Vector3.Lerp(upwardsHookLerp, (hookPoint - transform.position).normalized * Vector3.Distance(transform.position, hookPoint) * propelPower, .03f);
|
||||
// movementController.Move(upwardsHookLerp * Time.deltaTime);
|
||||
// isGrappled = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void getGrapplePoint(){
|
||||
// //if E or left face gamepad button is pressed is slightly pressed
|
||||
// if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
|
||||
// {
|
||||
// if (!isGrappled) //If we are not grappling
|
||||
// {
|
||||
// if(Physics.Raycast(cam.transform.position, cam.transform.forward, out RaycastHit raycastHit)){
|
||||
// if(raycastHit.collider.gameObject.transform.tag == "HookPoint"){
|
||||
// isGrappled = true;
|
||||
// hookPoint = new Vector3 (raycastHit.point.x,raycastHit.point.y,raycastHit.point.z);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using UnityEngine.UI;
|
|||
|
||||
public class PlayerMovement : NetworkBehaviour
|
||||
{
|
||||
//Controller object
|
||||
//Scripts
|
||||
public PlayerStats pStats;
|
||||
|
||||
|
|
@ -17,8 +16,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
|
||||
private Vector3 moveZ;
|
||||
private Vector3 moveX;
|
||||
private Vector3 driftVel;
|
||||
private Vector3 lerpY;
|
||||
public Vector3 driftVel;
|
||||
|
||||
//Player prefab
|
||||
private GameObject parentObj;
|
||||
|
|
@ -29,11 +27,11 @@ public class PlayerMovement : NetworkBehaviour
|
|||
//Jump value
|
||||
public int curJumpNum; // current Jumps used
|
||||
private bool jumpHeld; // Is jump being held
|
||||
float coyJumpTimer = 0.2f; // Default Coyote Jump time
|
||||
float coyJumpTimer = 0.1f; // Default Coyote Jump time
|
||||
float curCoyJumpTimer; // current Coyote Jump time
|
||||
public float lowJumpMultiplier; // Short jump multiplier
|
||||
public float fallMultiplier; // High Jump Multiplier
|
||||
private float g = 0; // the y velocity
|
||||
public float g = 0; // the y velocity
|
||||
|
||||
//Glide Values
|
||||
bool tempSet = false;
|
||||
|
|
@ -44,7 +42,6 @@ public class PlayerMovement : NetworkBehaviour
|
|||
private Vector3 impact = Vector3.zero;
|
||||
private float distToGround;
|
||||
|
||||
|
||||
//Wallrunning
|
||||
private WallRun wallRun;
|
||||
|
||||
|
|
@ -73,14 +70,14 @@ public class PlayerMovement : NetworkBehaviour
|
|||
private Rigidbody rB;
|
||||
private CapsuleCollider capCol;
|
||||
private bool firstHit = false;
|
||||
//private bool heldDown = false; //Variable for testing ragdoll reenable if needed
|
||||
//private bool heldDown = false; //Variable for testing Ragdoll reenable if needed
|
||||
private bool beginRagTimer = false;
|
||||
private float ragTime;
|
||||
private Vector3 prevRot;
|
||||
private Vector3 hitForce;
|
||||
|
||||
//Slide Variables
|
||||
private bool isSliding = false;
|
||||
public bool isSliding = false;
|
||||
private float originalTraction;
|
||||
private RaycastHit ray;
|
||||
private Vector3 up;
|
||||
|
|
@ -89,6 +86,9 @@ public class PlayerMovement : NetworkBehaviour
|
|||
//Blink
|
||||
private Blink blink;
|
||||
|
||||
private GrapplingHook grapple;
|
||||
|
||||
|
||||
//Animation controller
|
||||
Animator animator;
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
moveController = GetComponent<CharacterController>(); // Character Controller
|
||||
rB = GetComponent<Rigidbody>(); //Rigid Body
|
||||
capCol = GetComponent<CapsuleCollider>(); // Capsule Collider
|
||||
capCol.enabled = false;
|
||||
capCol.enabled = true;
|
||||
parentObj = transform.parent.gameObject;
|
||||
animator = GetComponent<Animator>();
|
||||
|
||||
|
|
@ -106,22 +106,22 @@ public class PlayerMovement : NetworkBehaviour
|
|||
pStats = GetComponent<PlayerStats>(); // PlayerStats
|
||||
wallRun = GetComponent<WallRun>(); //Wallrun
|
||||
blink = GetComponent<Blink>(); //Blink
|
||||
grapple = GetComponent<GrapplingHook>();
|
||||
|
||||
//Get parents up direction
|
||||
up = GetComponentInParent<Transform>().up;
|
||||
|
||||
//
|
||||
//Coyote Timer Initialization
|
||||
curCoyJumpTimer = coyJumpTimer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
distToGround = GetComponent<Collider>().bounds.extents.y;
|
||||
|
||||
// Don't do movement unless this is the local player controlling it
|
||||
// Otherwise we let the server handle moving us
|
||||
|
||||
if (!IsLocalPlayer) { return; }
|
||||
|
||||
// Don't lock the cursor multiple times if this isn't the local player
|
||||
|
|
@ -130,8 +130,6 @@ public class PlayerMovement : NetworkBehaviour
|
|||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
|
|
@ -167,10 +165,8 @@ public class PlayerMovement : NetworkBehaviour
|
|||
g -= pStats.PlayerGrav * Time.deltaTime;
|
||||
rB.AddForce(new Vector3(0,g,0));
|
||||
}
|
||||
|
||||
//TEMP FOR TESTING
|
||||
//Checks if player should respawn
|
||||
//Respawn();
|
||||
Respawn();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -200,6 +196,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
//Slide Function
|
||||
Slide();
|
||||
|
||||
|
||||
//move animation
|
||||
//if vel from input is greater than 0, start sprinting animation
|
||||
if (PlayerSpeed() > 0.1)
|
||||
|
|
@ -209,8 +206,9 @@ public class PlayerMovement : NetworkBehaviour
|
|||
if(animator != null) animator.SetBool("isRunning", true);
|
||||
}
|
||||
//if low enough movement from player (this will be still at this value) stop animation
|
||||
else if (driftVel.magnitude < .510f)
|
||||
else if (driftVel.magnitude < .05f)
|
||||
{
|
||||
driftVel = Vector3.zero;
|
||||
if(animator != null) animator.SetBool("isRunning", false);
|
||||
}
|
||||
|
||||
|
|
@ -229,21 +227,18 @@ public class PlayerMovement : NetworkBehaviour
|
|||
pStats.CurVel = 0.0f;
|
||||
return pStats.CurVel;
|
||||
}
|
||||
|
||||
//If current speed is below min when pressed set to minimum speed
|
||||
else if (pStats.CurVel < pStats.MinVel)
|
||||
{
|
||||
pStats.CurVel = pStats.MinVel;
|
||||
return pStats.MinVel;
|
||||
}
|
||||
|
||||
// while the speed is below max speed slowly increase it
|
||||
else if ((pStats.CurVel >= pStats.MinVel) && (pStats.CurVel < pStats.MaxVel))
|
||||
{
|
||||
pStats.CurVel += pStats.Acc;
|
||||
return pStats.CurVel;
|
||||
}
|
||||
|
||||
//If the players speed is above or equal to max speed set speed to max
|
||||
else
|
||||
{
|
||||
|
|
@ -257,7 +252,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
//Apply Impact for when force needs to be applied without ragdolling
|
||||
public void AddImpact(Vector3 dir, float force)
|
||||
{
|
||||
if (!IsLocalPlayer) { return; }
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
//Normalize direction multiply by force and add it to the impact
|
||||
dir.Normalize();
|
||||
|
|
@ -274,7 +269,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && !isSliding)
|
||||
{
|
||||
if(wallRun.IsWallRunning()){
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 20f);
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 10f);
|
||||
g = pStats.JumpPow;
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +285,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
lastTimeJumped = Time.time;
|
||||
|
||||
//If grounded no jumps have been used and coyote Timer is refreshed
|
||||
if(isGrounded){
|
||||
if(isGrounded && g == 0){
|
||||
curCoyJumpTimer = coyJumpTimer;
|
||||
curJumpNum = 0;
|
||||
}
|
||||
|
|
@ -300,14 +295,14 @@ public class PlayerMovement : NetworkBehaviour
|
|||
//if jump is being held coyote timer is zero
|
||||
if(jumpHeld) curCoyJumpTimer = 0;
|
||||
|
||||
if(grapple.isGrappled && curJumpNum == 2) curJumpNum = 1;
|
||||
|
||||
//If space/south face gamepad button isn't being pressed then jump is false
|
||||
if (Input.GetAxis("Jump") == 0){
|
||||
jumpHeld = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Get and update PlayerValues for other scripts
|
||||
//Get jumpHeld
|
||||
public bool GetJumpPressed(){
|
||||
|
|
@ -380,7 +375,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
{
|
||||
if (transform.position.y < -5)
|
||||
{
|
||||
transform.position = new Vector3(1f, 3f, 1f);
|
||||
TeleportPlayer(new Vector3(0,100,0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -435,22 +430,21 @@ public class PlayerMovement : NetworkBehaviour
|
|||
private void GravityCalculation(float grav){
|
||||
//apply slight upwards force for jump smoothing when g < 0
|
||||
if(g < 0){
|
||||
g += grav * (fallMultiplier - 1) * Time.deltaTime;
|
||||
g += grav * (fallMultiplier - 1) * Time.deltaTime;
|
||||
}
|
||||
|
||||
//apply smaller upwards force if jump is released early when jumping creating a short jump
|
||||
else if (g > 0 && !Input.GetButton("Jump")){
|
||||
g += grav * (lowJumpMultiplier - 1) * Time.deltaTime;
|
||||
g += grav * (lowJumpMultiplier - 1) * Time.deltaTime;
|
||||
}
|
||||
|
||||
//apply gravity if not grounded and coyote timer is less than 0
|
||||
if((isGrounded == false && curCoyJumpTimer <= 0)){
|
||||
g -= grav * Time.deltaTime;
|
||||
if(isGrounded == false && curCoyJumpTimer <= 0){
|
||||
g -= grav * Time.deltaTime;
|
||||
}
|
||||
|
||||
//else don't apply gravity
|
||||
else{
|
||||
g = 0;
|
||||
g = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -472,7 +466,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
{
|
||||
isGrounded = true;
|
||||
// handle snapping to the ground
|
||||
if (groundHit.distance > moveController.skinWidth)
|
||||
if (groundHit.distance > moveController.skinWidth && !grapple.isGrappled)
|
||||
{
|
||||
moveController.Move(Vector3.down * groundHit.distance);
|
||||
}
|
||||
|
|
@ -504,6 +498,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
rB.isKinematic = true;
|
||||
rB.detectCollisions = false;
|
||||
transform.localEulerAngles = prevRot;
|
||||
CancelMomentum();
|
||||
}
|
||||
|
||||
//When to begin the ragdoll timer
|
||||
|
|
@ -566,7 +561,7 @@ public class PlayerMovement : NetworkBehaviour
|
|||
vel = Vector3.zero;
|
||||
moveX = Vector3.zero;
|
||||
moveZ = Vector3.zero;
|
||||
moveController.enabled = false;
|
||||
driftVel = Vector3.zero;
|
||||
}
|
||||
|
||||
private IEnumerator RespawnTimer()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user