I want triggers that work locally in a network game, i.e. for each player on his own machine only. Here's my current code, this script is attached to all the objects I want to trigger: Code (csharp): function Awake() { renderer.enabled = false; // start out invisible } function OnTriggerEnter (other : Collider) { renderer.enabled = true; // make the object visible } function OnTriggerExit (other : Collider) { renderer.enabled = false; // make the object invisible } I have a collider around my objects that is larger than the object itself and set to trigger. So when a player comes close to the object, it becomes visible, when he walks away again, it disappears (I also have a nice fade effect, but I left that out here). But my problem is that this makes the object visible to player A when player B comes close to the object. And that's not what I want. The object should only be visible to whatever player triggered it. So what's the magic bit that I'm missing here?
Sorry to post with no answer. But I am interested in this too. For instance, when you are under water, turning on a dark, dense fog makes a pretty convincing looking water. But then everyone outside on the land, will suddenly be in a dense, dark fog. Would be interesting to be able to assign a few things to a specific camera or player. =my two cents.
What you want to do is use the information that is sent to your Event handlers to find out who collided with your trigger/collider... Code (csharp): function OnTriggerEnter(other : Collider) { if (other.gameObject.name == "MyDude") { DoStuff(); } } Here's all the stuff you can access from the Collider: http://unity3d.com/support/documentation/ScriptReference/Collider.html -Jeremy
On a networked game you would also add a check to make sure the object is yours. If all the objects are the same on all players (instead of each player having a different game object entirely). Code (csharp): function OnTriggerEnter(other : Collider) { if (other.gameObject.name == "MyDude" other.networkView.isMine) { DoStuff(); } } -Jeremy
Thanks, this helps. Is there a better way than to test for the name? Like testing if it has a character controller attached or something?
I figured out a great solution to this - using tags, it's very simple: Code (csharp): if (other.networkView.isMine other.gameObject.tag == "Player") { // do something }