Hello ppl hope you doing well, so I recently got this problem where the editor stopped calling Update function in one particular script of my project. All the major dumb mistakes that may cause this issue are already like “Penta checked” for now, so its enabled, its attached to the object the object is enable, its inheriting from MonoBehaviour and all of thouse stuff are completely correct.
I’ve noticed that when I change the Update() to FixedUpdate() it works, but its bugging me that its happening only in this particular script to Find an Object With Tag.
Also some ppl are having this issue on a very old thred so I reposted it to see I someone else have any solution to this
This simple script works in 2020.3.5f1, both Update() and Instantiate() are called:
using UnityEngine;
public class Test : MonoBehaviour
{
[SerializeField] private GameObject objectPrefab;
private void OnEnable()
{
Debug.Log("Hello there!");
}
// Update is called once per frame
private void Update()
{
InstantiateObject();
}
private void InstantiateObject()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Instantiate(objectPrefab, Vector3.zero, Quaternion.identity);
}
}
}
here is the script with FixedUpdate()
notice its running “properly” but clicking the board, not the bull, do not add anything to hierarchy evan thou it prints the “splash”
How comes? It is working in all the other scripts also it does work if I change to FixedUpdate(), BTW: Angus is the tag of the bull and yes its a prefab.
I don’t know what to say; it just appears that both Update() and Instantiate() work in 2020.3.5f1.
Maybe you’d need to share your project with someone who is more knowledgeable than me so that they can take a look. You could file a bug report about Update() not working for you in this particular case. Sorry that I cannot help more.
Dont worry, no need to apologize also you did what you could but its really weird, I’ve posted more to make sure it wasnt me who’s missing something dumb about this script because really I’ve tried everything even delete de script and start over from scratch with other names and stuff nothing is helping, ty for all your help guys, I’ll use this post in the bug report.
Looking at your code I suspect that it can’t find the target object, as this would result in no debug output the way you’ve coded it. Try putting a debug.log after target = GameObject.FindWithTag("Angus"); and see if you get some output in the console.
Sorry but the problem isnt to find the target or not, in FixedUpdate() it works, the code finds the target normally, in other scripts it does too and I use the same technic in all of them
You are saying that update isn’t being called as you see no debug log output, but the way you have it currently there isn’t a debug log that covers every condition in your update code.
You need to fix that before you can be sure update isn’t being called.