playMaker

Author Topic: Camera Controller for Top Down Space Shooter  (Read 2458 times)

Phillament

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Camera Controller for Top Down Space Shooter
« on: December 07, 2013, 01:06:24 AM »
Hi, I'm making a top down arena shooter type game, and I'd like to make the camera follow the player as they move about the level. I've been parenting the camera to the player, and that works fine early in development, but I'd like to know how I can make the camera follow the player through state machines. I tried the first person and third person camera tutorial on the Hutong Games Youtube page, but that doesn't seem to work at all for my case. The only thing it does is jump to where the player is at the start of the play session. It doesn't follow the player.

I'm using unity 2D, and I've attached some screen caps if that helps.

Phillament

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Re: Camera Controller for Top Down Space Shooter
« Reply #1 on: December 07, 2013, 01:25:26 AM »
Okay, I realized what was off about my version of the FSM. I was referring to a prefab of the player, instead of the player in the Hierarchy. Changing this made all the difference. I still don't understand why this change made it work, though.

Aren't prefabs supposed to be sort of like the master copy? I thought by assigning the set game object to the player prefab would work just fine. Apparently not, hmm. Anyone know why that is?

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Re: Camera Controller for Top Down Space Shooter
« Reply #2 on: December 07, 2013, 02:07:38 AM »
The prefab is a referenced object. Like you said, it works great as a "master copy" You can copy it all over your scene, and change the prefab, and all the copies change. A very useful function.

When you "target" a prefab, you're targeting a source. Since it doesn't exist within the scene, whatever is targeting it can't find it.

Imagine you're baking a cake and you need flour. You know the flour exists at the store, but knowing it's at the store (or even which exact shelf it's on) doesn't help you bake the cake. You have to have the flour in your kitchen to make use of it. Prefabs are like storage for assets - the game is aware of them, but can't make use of them until they're present within the scene.