Can't fix a warning

Hey there. So, back a bit when we were doing clean up of folders and such, a few things broke for me. Especially when I went and moved my scripts into new folders. So far I’ve managed to fix everything but I’m still having a problem with FollowCamera prefab. In the Hierarchy object I can set the target to player, but when I go to apply the override to the prefab, nothing happens. The prefab doesn’t update and when I go back to the apply button, it still shows that prefab isn’t updated. When I go to edit the prefab directly, Player doesn’t show as an available target, only my other two scripts show.

I think yesterday, when I first noticed it, I tried to simply recreate the Follow Camera object, but I’m still having the problem. I could try re-creating it again, just in case I didn’t actually do it yesterday, but I’d much rather understand why it’s not working and how to fix it properly. If possible.

Thanks.

If the Follow Camera and the Player are separate objects, you won’t be able to save the link to the player in the prefab. It simply doesn’t make any sense to save a reference to an object in the heirarchy in the prefab because the prefab might go into a scene where that object does not exist.
You can have a parent GameObject that contains both the Player and the FollowCamera, and prefab THAT, then within the Prefab editor you can make the link, but your FollowCamera prefab in the asset folder will still not be updated, only the Prefab parent object you’ve created that contains an instance of the FollowCamera and Player.

I’m not sure I understand. This screen shot looks exactly the same as in the Create a Fixed Follow Camera lecture, and up until I moved things around to organize my folders, it was working fine.

  • The FollowCamera in the heirarchy will allow me to add the Player to the Target field.

  • Clicking Override/Apply shows that I’ve got an update to FollowCamera but clicking Apply All results in no changes to the prefab.

  • If I go into the prefab, I can drag the player prefab into the target field, but if I back out and go back in, the field is empty. Also, clicking the button to the right right of the field only brings up FollowCamera and MainCamera as options.

So, I’m confused when you say that “If the Follow Camera and the Player are separate objects, you won’t be able to save the link to the player in the prefab.” because, is that not how it is the lecture? Like, it feels like you’re saying that the way it’s done in the lecture isn’t possible. But in the lecture, neither the Player or the FollowCamera are contained inside another game object…Just like in my screenshot.

If I’m slightly understanding what you’re saying in your second sentence, I’m pretty sure I’ve used the prefabs in the target fields. How can I tell if something is using prefab directly instead of whatever is in the hierarchy? if that’s what you’re even getting at…

Also, thanks for helping me wrap my brain around this…

What I’m trying to say is that no Prefab in the Assets directory can contain a direct reference to an object in the scene heirarchy.
This is an example of linking within a prefab that can work in a scene file.
Later in the course, our player and the camera will be under a prefab called Core. The Follow Camera in Core contains a reference to the Player in Core. Then when the Core is brought into the scene, the linking is correct. Without this parenting, you would have to link the camera to the player manually in the scene.

So, until they’re put into the Core object, my FollowCamera prefab isn’t supposed to have the Player as the target right now? Only the FollowCamera in the heirarchy should?

Correct.

1 Like

Okay, I think I’m getting it. Now back to figuring out why my attack isn’t working. Thanks for the help! Cheers!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms