$200 Worth of Models if you can Fix my Problem!

Update:
Frustrated as hell,
that’s why I’m offering 4 (an average of $200) models of your choice from my website to whoever can give me a solution and fix this problem. This is a one time deal and only goes for the person that gets this working for me.

More Problems:
I have continued to mess with the settings and no luck. I am supposed to be using a network rigid body view right?? I even tested it with 4 players and on each player’s separate screens I controlled all four players but only with in the active screen. I am completely perplexed. I have no idea why it’s not working.

This is the only thing standing between getting my game to be publicly played. The modeling and scenery won’t take me long but the coding and networking is killing me. Please someone help me out this is the most frustrating thing. I’m surprised people haven’t had similar problems.

Original Post:
I used the M2H tutorial as starting point for creating an online multiplayer shooting game.

I plan to make a free to play 3rd/first person online shooter. I’m great at modeling and everything else except for programming. I’m not the best programmer. Once I get this bug/error out of the way I can really start making my game and its’ levels. I didn’t want to start the real modeling until I was certain I could get this problem fixed.

Whats hard about my game is that I completely redid my character because I’m doing a 3rd/FPS shooter game.

Everything works fine, I connect both players online and I can chat with the other player. Then when I control my player I also control the other player that is online and vise versa. I have done everything that the other prefabed player did on the m2h example and still no luck. Is there something simple I’m missing or is there something I didn’t do right?

How can I make it so the players are controlled separately?

I don’t really know how to give you an example I’ll take a screen of my character.

As you can see below there are 2 completely different games running even though I’m connected to the same network. You can tell by the crates in the back. I’m really confused and I don’t know what’s causing this.



i think you have the authoritative setup so the server instantiates both players and controls them. in the example the server sends an rpc to the client telling it to take control of the player.
maybe you missed that part.

Alright thanks. Where can I change it so they move independently?

Check out the M2H 3rd tutorial - just use the scripts from there instead.

Should be quite easy and should work perfect for your shooter.

The only code you will have to write by yourself is about damage and bullets over the network.

If you are using the code from Example 4 on the M2H tutorial, try encompassing your controller code in the following if statement:

if(networkView.isMine){

}

Alright thanks for the suggestions I’ll try them both.

As for coding I don’t know much so I wouldn’t know where to put that if statement. I also wouldn’t know how to make the machine gun script work over the network. The one that’s in the tutorial is okay but it lacks effects.

I’m using the one from TwiiK’s Third Person Learning Project but it was a pretty basic script just liked the bullet hole effects. So should I just use machine gun from M2h’s tutorial?

Also why do I control both players it’s the most frustrating thing. Where would I add the encompassing if statement? What I don’t get is that the player are on completely different levels even though they connect through the server. Does it have anything to do with animations over a network?

Thanks again for the suggestions I really hope I can get this fixed.

Like i said before, if the server (in an authoritative setup) instantiates the players, he is the owner and therefore has control over them.
Thats why it’s authoritative, a way for the server to prevent cheating. The players get control after the server has told them to control the gameobject.
Look for the script where you get that call.
The networkView.isMine should be called there.

Yes but I don’t know how to set it up and what to do. I just use the scripts that are there from the tutorial.

How do I change it can you give me details?

If you are using the FPSWalker script from the example, try putting the if statement as the first line in the FixedUpdate() function. Open it there and close it right before the end of the function.

Thanks, I tried this and still no luck.

Did I put it in the right spot?

I still control both the characters

/* 
*  This file is part of the Unity networking tutorial by M2H ([url]http://www.M2H.nl[/url])
*  The original author of this code is Mike Hergaarden, even though some small parts 
*  are copied from the Unity tutorials/manuals.
*  Feel free to use this code for your own projects, drop us a line if you made something exciting! 
*/
#pragma strict

var speed = 6.0;
var jumpSpeed = 8.0;
var gravity = 20.0;

private var moveDirection = Vector3.zero;
private var grounded : boolean = false;

function FixedUpdate() {
	if(networkView.isMine){ 

	} 	
	
	if (grounded) {
		if(!FPSChat.usingChat){
			// We are grounded, so recalculate movedirection directly from axes
			moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
			moveDirection = transform.TransformDirection(moveDirection);
			moveDirection *= speed;
		
			if (Input.GetButton ("Jump")) {
				moveDirection.y = jumpSpeed;
	        
				
			}
		}
	}

	// Apply gravity
	moveDirection.y -= gravity * Time.deltaTime;
	
	// Move the controller
	var controller : CharacterController = GetComponent(CharacterController);
	var flags = controller.Move(moveDirection * Time.deltaTime);
	grounded = (flags  CollisionFlags.CollidedBelow) != 0;
}

//@script RequireComponent(CharacterController)

Your closing bracket needs to be at the end of the function, not at the beginning. Here’s an example FixedUpdate function:

function FixedUpdate() { 
   if(networkView.isMine){      
     if (grounded) { 
        if(!FPSChat.usingChat){ 
           // We are grounded, so recalculate movedirection directly from axes 
           moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); 
           moveDirection = transform.TransformDirection(moveDirection); 
           moveDirection *= speed; 
        
           if (Input.GetButton ("Jump")) { 
              moveDirection.y = jumpSpeed; 
            
              
           } 
        } 
     } 

     // Apply gravity 
     moveDirection.y -= gravity * Time.deltaTime; 
    
     // Move the controller 
     var controller : CharacterController = GetComponent(CharacterController); 
     var flags = controller.Move(moveDirection * Time.deltaTime); 
     grounded = (flags  CollisionFlags.CollidedBelow) != 0; 
    }
  } 
}

the code should look like this:

/*
*  This file is part of the Unity networking tutorial by M2H ([url]http://www.M2H.nl[/url])
*  The original author of this code is Mike Hergaarden, even though some small parts
*  are copied from the Unity tutorials/manuals.
*  Feel free to use this code for your own projects, drop us a line if you made something exciting!
*/
#pragma strict

var speed = 6.0;
var jumpSpeed = 8.0;
var gravity = 20.0;

private var moveDirection = Vector3.zero;
private var grounded : boolean = false;

function FixedUpdate() {
   if(networkView.isMine){

   if (grounded) {
      if(!FPSChat.usingChat){
         // We are grounded, so recalculate movedirection directly from axes
         moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
         moveDirection = transform.TransformDirection(moveDirection);
         moveDirection *= speed;
      
         if (Input.GetButton ("Jump")) {
            moveDirection.y = jumpSpeed;
          
            
         }
      }
   }

   // Apply gravity
   moveDirection.y -= gravity * Time.deltaTime;
   
   // Move the controller
   var controller : CharacterController = GetComponent(CharacterController);
   var flags = controller.Move(moveDirection * Time.deltaTime);
   grounded = (flags  CollisionFlags.CollidedBelow) != 0;
}
}

//@script RequireComponent(CharacterController)

You need to place all the code inside of the first if statement or else it will continue to run the code regardless.

I put the code in got a couple syntax errors and fixed them, but it still doesn’t work. I’m still controlling both characters when I walk.

I’m using the network view and the fps walker from the tutorial…what else could it be?

I suppose you skipped the spawn script part. ( Add spawnscript.js from the M2H tutorial to an empty game object )

This is the script witch in combination with the playerscript ( tutorial 3 ) gives you the control of your unit ( separate from other players ).

I did that and it gave me 4 player in the game but I still controlled all of them. I don’t get it

How does it give you players ? By using the spawnscript players should be spawned only on connection o0

-Jedy

Have you fixed this? i can fix it for you, we can talk over skype.

I would hope so, as the post you bumped is 9 months old.

lol hahah :slight_smile:

Thank goodness for Quietus. if it hadn’t been for his keen sense of date checking I might have replied to this thread, also!

…doh!