Tasharen Entertainment Forum
Support => TNet 3 Support => Topic started by: Pigomigo on April 20, 2013, 12:15:14 PM
-
I understand why TNManager.Create doesn't return a reference to the new object. However, I am confused how I would do any setup on that object that was custom to the specific instance that was created.
For example, lets say I have a player who is flying a jet. He wants to fire a missile that will home in on a specific target in the level. I have a missile prefab, but when I instantiate the missile it doesn't know what its target is. I need to pass that data to the specific missile instance that was created, but my player doesn't have a reference to it, so I am not sure how.
What is the correct way to handle this? I could have the player create a missile, then wait around for an unclaimed missile object to exist, then "claim" it and do stuff with it, but this seems cumbersome. Is there a better way?
-
In the start method of the instantiated object check
if (TNManager.isThisMyObject) then do whatever you need to track this object by this player.
-
TNManager.isThisMyObject should ideally be checked in Awake() rather than Start(). If you need it in Awake, Update, or any other function, check tno.isMine (where tno is TNObject).