x


Problem with Camera instantiating

Hello..

Im instantiating my character.. (Its working really fine).

But how to assign the camera to the character now? The camera and the player are in the same prefab. I tried to use Parenting, but now the camera is always looking at the newest created player.

Im using this on the camera:

var target : Transform;
target = GetComponent(Transform).parent;

Is there a better way for instantiating? I just found "Find by tag" but isnt it the problem that it will search one of the many players and not the newest?

Thank you very much. I would be glad for a little easy example.

My second problem: Im using

function Awake(){
    if(!networkView.isMine){
        enabled=false;  
    }
}

//Other script

function Awake(){
    Spawnplayer();
    }

function Spawnplayer(){
    var myNewTrans : Transform = Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
}

I get every time a player connect a new Object.. the problem is that all other players (Exept the newest one are loosing networkView.Ismine ... why?

more ▼

asked Jul 24 '10 at 12:23 AM

Tobias gravatar image

Tobias
378 50 54 66

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
  1. target=transform.parent
  2. Where is the

     if(!networkView.isMine){
            enabled=false;  
        }
    

    located , if its in an empty game object which serves as a manager or something you should put the code in OnLevelWasLoaded , since awake will only execute the code when it gets instantiated by whatever player

more ▼

answered Jan 29 '11 at 07:32 PM

YeOldeSnake 1 gravatar image

YeOldeSnake 1
205 11 12 19

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5099
x3015
x1683
x1260
x711

asked: Jul 24 '10 at 12:23 AM

Seen: 1687 times

Last Updated: Jul 24 '10 at 01:27 AM