Skip to content
Snippets Groups Projects
Commit aa174c49 authored by Chiquita Ahsanunnisa's avatar Chiquita Ahsanunnisa
Browse files

fix: infinitely create new game object

parent f622ca9a
1 merge request!55fix/pet + cheat init
...@@ -14,10 +14,7 @@ public class BuffPetAIController : PetAIController<BuffPet> ...@@ -14,10 +14,7 @@ public class BuffPetAIController : PetAIController<BuffPet>
// Get allowed farthest point from owner // Get allowed farthest point from owner
Vector3 direction = MathUtils.GetDirectionVectorFlat(GameController.Instance.player.transform.position, pet.Owner.CompanionController.transform.position); Vector3 direction = MathUtils.GetDirectionVectorFlat(GameController.Instance.player.transform.position, pet.Owner.CompanionController.transform.position);
Vector3 to = pet.Owner.CompanionController.transform.position - Vector3.Normalize(direction) * pet.stateController.maxDistFromOwner; Vector3 to = pet.Owner.CompanionController.transform.position - Vector3.Normalize(direction) * pet.stateController.maxDistFromOwner;
GoToward(to);
Transform target = new GameObject().transform;
target.position = to;
GoToward(target);
} }
else // AI_IDLE_STATE else // AI_IDLE_STATE
{ {
......
...@@ -38,6 +38,11 @@ public abstract class PetAIController<T> where T : Companion ...@@ -38,6 +38,11 @@ public abstract class PetAIController<T> where T : Companion
nav.destination = target.position; nav.destination = target.position;
} }
public void GoToward(Vector3 position)
{
nav.destination = position;
}
private void OnDamaged() private void OnDamaged()
{ {
nav.velocity = Vector3.zero; nav.velocity = Vector3.zero;
......
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