I got a little issue I’m running into regularly:
I got an object with an animator attached which has an initial state where it is practically instantly made invisible. But in reality it is not turned invisible instantly but flashes up for a frame.
The only workaround so far is to have the object made manually invisible in the inspector while editing which is really tedious if I want to change something. (Because I have to make it visible again, make my edits and turn it back invisble again, when I’m done)
My biggest problem with this is, that the animator seems to need a whole frame until it finally applies the first frame of it’s initial state.
Any thoughts on that. Anyoune experienced the same issue?
Which forces the animator to update (i.e. to do whatever is set in the first frame of it’s initial state) ahead of it’s usual time. Seems to work so far!
If your animator’s Update Mode is set to Animate Physics, your object will refresh at a different rate than the view which may cause the flash. If you don’t need physics update, set the Update Mode to Normal.
I tried on my project and it worked, but I still wanted to have physics update so instead I decided to initialize the object on Awake in a initial invisible state, and to switch to a visible state later in the game when the object is used.
If you cannot do that either, you can do like anilo said, making the target object invisible in your script, just after the object is created (so either Awake or in the method that spawn the object). If the rendered object is at the component root, you cannot just deactivate the object since it will also prevent the animator from updating, but you can deactivate the rendering components.
In your comment, you said that the animation curve would override your changes. But since your initial state is also supposed to make the object invisible (hence the flash), it should not revert what you did in the script so the object will start and remain invisible until the animation makes it visible.