mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
look priority when grappling
This commit is contained in:
@@ -27,6 +27,7 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
|
||||
////Objects Sections
|
||||
GameObject parentObj; // Parent object
|
||||
public Camera cam;
|
||||
////
|
||||
|
||||
////Components Section
|
||||
@@ -479,17 +480,31 @@ 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
|
||||
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