|
Post by chairiko on Jul 13, 2020 15:17:58 GMT
Replace CheckForCharacterAlive in LockOn script with this:
protected virtual void CheckForCharacterAlive()
{
if (currentTarget && !isCharacterAlive() && inTarget)
{
ResetLockOn();
inTarget = false;
SearchAgain();
}
} Add the following below it (this allows for if there are no enemies near, the coroutine will make it not lock on):
protected virtual void SearchAgain()
{
StartCoroutine(SearchForNearbyTarget());
Search();
}
protected virtual IEnumerator SearchForNearbyTarget()
{
yield return new WaitForSeconds(0.1f);
CheckAgain();
}
protected virtual void CheckAgain()
{
if (!isCharacterAlive())
{
ResetLockOn();
inTarget = false;
StopLockOn();
}
}
protected virtual void Search()
{
if (!inTarget && currentTarget)
{
isLockingOn = true;
inTarget = true;
tpInput.cc.isStrafing = true;
LockOn(isLockingOn);
SetTarget();
}
}
|
|