What is the trick to move the combat Target component up?
It wants me to open the character prefab for some reason.
What is the trick to move the combat Target component up?
It wants me to open the character prefab for some reason.
Do you mean moving the component up in the inspector?
It’s all related to how a prefab is organized. The object in the scene (or a child prefab) must have it’s children and objects in the same order as the prefab it’s based on. As the error message says, you can open the prefab and reorder the items. The item in the scene will then be reordered to conform to the changes.
If one is following the course in the typical order then it’s likely that you added the AIConversant after you added the CombatTarget (or it was already there), so the CombatTarget will already be higher in the component list. Since removing it in an earlier lecture was a Prefab Variant override it is just marked as “removed”, but still there in spirit, so you can revert this and restore the original position of the CombatTarget component, rather than adding a new instance of the component at the bottom.
As an aside, now that we check enabled
in the CombatTarget code, it might be useful to manually enable or disable this component. To get Unity to show you the little tickbox for this, you can just create an empty Start
method. I’m not sure why Unity doesn’t show you this tickbox if you don’t have this method defined. It probably works with Awake()
and Update()
too, amongst others.
Specifically Start() and Update(). If a MonoBehavior has neither of these, then enable is meaningless. Unchecking enable only prevents Start() or Update() from firing (or any Coroutines from starting). As a matter of fact, in a disabled component, you can still manually call any public method on a disabled component and it will work just fine.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.