Search Unity

Question on Space Shooter Tutorial: Counting Points and Displaying the Score

Discussion in 'Community Learning & Teaching' started by josieheartthrob, Feb 15, 2015.

  1. josieheartthrob

    josieheartthrob

    Joined:
    Feb 6, 2015
    Posts:
    8
    I've been going through the Unity game tutorials and while finishing up the Space Shooter tutorial I came across a concept I don't quite understand. After scouring Unity I still haven't been able to grasp it. I guess my question has to do with the nature of references in scripting which I'm fairly new to scripting so I don't fully understand how references work.

    In the Counting Points and Displaying the Score tutorial at 11:22-11:48 it says that it doesn't make sense for a prefab to hold a reference to an instance of an object in a particular scene. My question is why does that not make sense?
     
  2. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Afternoon,

    ill try and write how i think of them (hope its right), this is just my ramblings, but fingers crossed someone with a bit more understanding will pop a note in.

    A prefab is a template, a blueprint on how to create a certain object within your scene.
    a prefab should, i believe, only hold references to other resources and assets, for example the player explosion prefab, or the bolt prefab. so basically a collection of templates to utilise for instantiation purposes.

    once you instantiate an object ie give it a presence in your scene , you can then have that object store details of something in your scene as it has been created.
    as a prefab, it cant store game object info as it is a concept and doesnt have any way of storing data or game info until it is created.