Skip to content
Snippets Groups Projects
Commit 4cd243d0 authored by Rozan Fadhil Al Hafidz's avatar Rozan Fadhil Al Hafidz
Browse files

fix: attacker pet death null pointer exception

parent 2173c3a9
Branches
Tags
No related merge requests found
...@@ -41,15 +41,22 @@ public class PetAttack : MonoBehaviour ...@@ -41,15 +41,22 @@ public class PetAttack : MonoBehaviour
if(arrowMoveRendering) if(arrowMoveRendering)
{ {
Vector3 targetPosition = enemyTarget.transform.position; try
targetPosition.y = 0; {
Vector3 targetPosition = enemyTarget.transform.position;
targetPosition.y = 0;
clonedArrow.transform.position = Parabola(arrowInCurrentBow.transform.position, targetPosition, 1, timerForArrow * 2 / 1f); clonedArrow.transform.position = Parabola(arrowInCurrentBow.transform.position, targetPosition, 1, timerForArrow * 2 / 1f);
if(timerForArrow >= anim.GetCurrentAnimatorStateInfo(0).length) if(timerForArrow >= anim.GetCurrentAnimatorStateInfo(0).length)
{
arrowMoveRendering = false;
}
gameObject.transform.LookAt(enemyTarget.transform);
}
catch (Exception e)
{ {
arrowMoveRendering = false; Debug.Log(e);
} }
gameObject.transform.LookAt(enemyTarget.transform);
} }
else else
{ {
...@@ -86,7 +93,7 @@ public class PetAttack : MonoBehaviour ...@@ -86,7 +93,7 @@ public class PetAttack : MonoBehaviour
arrowInCurrentBow = GameObject.Find("main_arrow"); arrowInCurrentBow = GameObject.Find("main_arrow");
clonedArrow = Instantiate(arrowPrefab, arrowInCurrentBow.transform.position, arrowInCurrentBow.transform.rotation); clonedArrow = Instantiate(arrowPrefab, arrowInCurrentBow.transform.position, arrowInCurrentBow.transform.rotation);
clonedArrow.gameObject.GetComponent<Arrow>().damageMultiplier = 100f;
timer = 0f; timer = 0f;
timerForArrow = 0f; timerForArrow = 0f;
arrowMoveRendering = true; arrowMoveRendering = true;
......
...@@ -79,9 +79,12 @@ public class PetHealth : MonoBehaviour ...@@ -79,9 +79,12 @@ public class PetHealth : MonoBehaviour
anim.SetBool("Dead", true); anim.SetBool("Dead", true);
PetBuff petBuff = pet.GetComponent<PetBuff>(); PetBuff petBuff = pet.GetComponent<PetBuff>();
if(petBuff.petType == PetTypeEnum.Aura) if (petBuff != null )
{ {
petBuff.NormalizedAura(); if(petBuff.petType == PetTypeEnum.Aura)
{
petBuff.NormalizedAura();
}
} }
Destroy(pet); Destroy(pet);
......
No preview for this file type
{"highestScoreList":[{"playerName":"CJ​","timeTakenToWin":525.9905395507813},{"playerName":"-​","timeTakenToWin":1000000000.0},{"playerName":"-​","timeTakenToWin":1000000000.0},{"playerName":"-​","timeTakenToWin":1000000000.0},{"playerName":"-","timeTakenToWin":1000000000.0}]} {"highestScoreList":[{"playerName":"Ucok​","timeTakenToWin":18.10793113708496},{"playerName":"Ucok​","timeTakenToWin":71.50775909423828},{"playerName":"CJ​","timeTakenToWin":525.9905395507813},{"playerName":"-​","timeTakenToWin":1000000000.0},{"playerName":"-​","timeTakenToWin":1000000000.0}]}
\ No newline at end of file \ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment