Update not recognizing changes in if condition floats, and simply not updating
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class UFOBossFollow : MonoBehaviour { public Transform Target; public GameObject Laser;
public float followSmoothingSpeed = 0.01f;
public float numberOfAttacks;
public float bossFinished;
public Vector3 playerOffset;
public Vector3 disappearOffset;
public Vector3 followingPosition;
public Vector3 smoothPositioning;
public bool startBossfight;
public bool attackPlayer;
private bool endUFOPartBossFight;
private void Start()
{
numberOfAttacks = 0f;
}
public void Update()
{
followingPosition = Target.position + playerOffset;
smoothPositioning = Vector3.Lerp(transform.position, followingPosition, followSmoothingSpeed);
Debug.Log("call");
if (attackPlayer == true)
{
transform.position = smoothPositioning;
}
else
{
}
}
public void UFOBossFight()
{
Debug.Log("Start Boss Fight");
Debug.Log(numberOfAttacks);
if (startBossfight == true && numberOfAttacks < 5)
{
attackPlayer = true;
Laser.SetActive(false);
if (attackPlayer == true)
{
StartCoroutine(PrepareAttackStep1(15f)); //Makes laser Active
StartCoroutine(PrepareAttackStep2(7f)); //Stops UFO Movement
attackPlayer = false;
StartCoroutine(PrepareFightAgain(15f)); //Reset fight in if conidtions met in loop
}
if (attackPlayer == false)
{
numberOfAttacks++;
}
if (numberOfAttacks == 4)
{
Debug.Log("End Boss Fight");
startBossfight = false;
numberOfAttacks = 0;
StartCoroutine(BossEvadedTextCall(5));
Debug.Log("Boss Evaded");
}
}
}
public void StartUFOBoss(bool startBoss)
{
startBossfight = startBoss;
endUFOPartBossFight = startBoss;
if (endUFOPartBossFight == true)
{
endUFOPartBossFight = false;
UFOBossFight();
}
}
I'm basically updating attackPlayer perfectly fine, but it's not being detected in FixedUpdate, therefore the object is not moving as it should, without any conditions, it works all the time.
I even tried calling FixedUpdate() in the UFOBossFight, and it worked but only updated it once..., so the ufo moved for a split second and then stopped again.
I tried both Update and FixedUpdate, and not difference..
Your answer
Follow this Question
Related Questions
How do GameObjects detect void Update and how to make my custom one. 0 Answers
Is there a way to check something every frame from within a coroutine? 1 Answer
Issuse with 3d Text Update or couple months thinking about error. How its works? 1 Answer
UpDate function not being called 1 Answer
Jerks and friezes at moving after upgrading to Units 5.6 (2D game) 0 Answers