mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 18:04:27 -05:00
look priority when grappling
This commit is contained in:
@@ -505,17 +505,29 @@ public class AerialStateManager : NetworkBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
//Finds the nearest hook to the player
|
||||
int FindHookPoint()
|
||||
{
|
||||
float least = maxGrabDistance;
|
||||
int index = -1;
|
||||
bool inSightLine;
|
||||
bool hookInSight = false;
|
||||
for(int i = 0; i<hookPoints.Length; i++)
|
||||
{
|
||||
distance = Vector3.Distance(gameObject.transform.position, hookPoints[i].transform.position);
|
||||
|
||||
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)
|
||||
{
|
||||
index = i;
|
||||
if(inSightLine){
|
||||
index = i;
|
||||
least = distance;
|
||||
hookInSight = true;
|
||||
}
|
||||
else if(!hookInSight && !inSightLine){
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
|
||||
Reference in New Issue
Block a user