mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
modified hook and adding testing
This commit is contained in:
@@ -69,6 +69,7 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
Vector3 raycastOffset;
|
||||
Vector3 lastPos;
|
||||
Ray groundRay; // ground ray
|
||||
//Raycasts to ensure player slips down steep ledges
|
||||
Ray angleRayLeft;
|
||||
Ray angleRayRight;
|
||||
Ray angleRayForward;
|
||||
@@ -77,6 +78,7 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
Ray angleRayRightL;
|
||||
Ray angleRayForwardB;
|
||||
Ray angleRayBackwardsF;
|
||||
///
|
||||
RaycastHit groundHit; // ground raycast
|
||||
|
||||
//Wallrun
|
||||
@@ -586,33 +588,54 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
//Modify This So it Actually gets the nearest hook with a preference for the one they are looking at
|
||||
//Finds the nearest hook to the player
|
||||
//Finds the nearest hook to the player with visual Preference
|
||||
int FindHookPoint()
|
||||
{
|
||||
float least = maxGrabDistance;
|
||||
int index = -1;
|
||||
bool inSightLine;
|
||||
bool hookInSight = false;
|
||||
float sightLineleastDistance = maxGrabDistance; // distance to check for sightline hookpoints
|
||||
float nonSightLineLeastDistance = maxGrabDistance; // distance to check for non sightline hookpoints
|
||||
int index = -1; // Default hook index
|
||||
bool inSightLine; // Whether a hook is in currently in sight line
|
||||
bool hookInSight = false; //Whether a hook was in sight
|
||||
|
||||
//Iterate through hookpoints
|
||||
for(int i = 0; i<hookPoints.Length; i++)
|
||||
{
|
||||
//checks player distance to current hook
|
||||
distance = Vector3.Distance(gameObject.transform.position, hookPoints[i].transform.position);
|
||||
|
||||
//Checks if the current hook is within the players view point
|
||||
Vector3 screenPoint = cam.WorldToViewportPoint(hookPoints[i].transform.position);
|
||||
inSightLine = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
|
||||
|
||||
if (distance <= least)
|
||||
//if the distance is less than the current closest closest sight line hook
|
||||
if (distance <= sightLineleastDistance)
|
||||
{
|
||||
//if the hook is in view point
|
||||
if(inSightLine){
|
||||
|
||||
//Update current grapple target
|
||||
index = i;
|
||||
least = distance;
|
||||
|
||||
//update closest sight line hook distance
|
||||
sightLineleastDistance = distance;
|
||||
|
||||
//A hook exists in sight line
|
||||
hookInSight = true;
|
||||
}
|
||||
else if(!hookInSight && !inSightLine){
|
||||
|
||||
//if no hookpoints are or has been in sight and the the distance is less than the current closest closest non sight line hook
|
||||
else if((!hookInSight && !inSightLine) && distance <= nonSightLineLeastDistance){
|
||||
|
||||
//update current grapple target
|
||||
index = i;
|
||||
|
||||
//Update the closest non sight line hook distance
|
||||
nonSightLineLeastDistance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//return the index of the closest hook with priority of ones in sightline
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user