This is my character control script. But it only controls the other player. Everything is perfect but for some reason you control each other not yourself. (And I know my scripts terrible I through it togethor quickly)
pragma strict
var projectile: Transform;
var gun : Transform;
var firerate = 50;
var rounds = 25;
var speed = 2;
var run = 25;
//var health = 100;
var ammotake = false;
private var hit: RaycastHit;
function OnGUI () {
GUI.Label (Rect (10, 75, 100, 20), "Rounds: " + rounds);
//GUI.Label (Rect (10, 100, 100, 20), "Health: " + health);
if(ammotake == true){
GUI.Label (Rect (10, 150, 200, 20), "Right click to take ammo");
}
}
function Update () {
if(networkView.isMine) {
if (Input.GetKeyDown(KeyCode.H)){
if(Screen.lockCursor == true){
Screen.lockCursor = false;
}
else if(Screen.lockCursor == false){
Screen.lockCursor = true;
}
}
}
var fwd = transform.TransformDirection (Vector3.forward);
if (Physics.Raycast (transform.position, fwd,hit, 2)){
if(hit.transform.tag == "ammo"){
ammotake = true;
if(Input.GetMouseButtonDown(1)){
Network.Destroy(hit.collider.gameObject);
rounds += 10;
}
}
}
else{
ammotake = false;
}
if(networkView.isMine) {
if (Input.GetKey(KeyCode.W)){
transform.Translate(Vector3.forward * Time.deltaTime * speed);
}
// if (Input.GetKey(KeyCode.Space)){
//rigidbody.AddForce(Vector3.up * 15);
//}
if (Input.GetKey (KeyCode.A)){
transform.Translate(Vector3.left * Time.deltaTime * speed);
}
if (Input.GetKey (KeyCode.S)){
transform.Translate(Vector3.back * Time.deltaTime * speed);
}
if (Input.GetKey (KeyCode.D)){
transform.Translate(Vector3.right* Time.deltaTime * speed);
}
if(Input.GetMouseButton(0)){
if(firerate > 50){
fire();
}
}
}
firerate += 1;
}
function fire(){
if(networkView.isMine) {
if(rounds >= 1 ){
var shoot = Network.Instantiate(projectile, gun.position, gun.rotation, 0);
firerate = 0;
rounds -=1 ;
}
}
}