So I making a farm game and I’m currently coding the “Bull” to go to the closest cow to mate with. It works for the first “mating” session and once done it goes into “hiding” to gain energy to go back into the “chase” state, once it’s in range of the cow it’ll go into the horny state and produce a cow, but the second time he goes over it starts spewing them out without switching back into the “hiding” state without making a few cows first.
public BullAIState Chase()
{
if (cow != null)
{
moveTo = cow;
if (Vector3.Distance(moveTo.position, transform.position) <= minMountDistance)
{
return BullAIState.HORNY;
}
}
}
This is the chase function once it has found the closest cow.
public BullAIState Horny()
{
Debug.Log("I am Fucking");
fuck = true;
if(fuck)
{
obj = (GameObject)Instantiate(babyCow, gameObject.transform.position, gameObject.transform.rotation);
cow = null;
moveTo = getRandomMoveTo ();
cow = null;
fuck = false;
return BullAIState.HIDING;
}
cow = null;
moveTo = getRandomMoveTo ();
return BullAIState.HIDING;
}
This is the horny state. I’ve put a few more “cow = null”'s in to try and make the cow move away but it won’t.
Does anyone have an idea about what could be causing this?