<commit_before>﻿var speed: int = 5;
var gravity = 5;
private var cc: CharacterController;

var bulletPrefab:GameObject;

function Start() {
	cc = GetComponent(CharacterController);
}

function Update(){
	if (GetComponent(NetworkView).isMine) {
		cc.Move(Vector3(Input.GetAxis("Horizontal") * speed * Time.deltaTime, -gravity * Time.deltaTime, Input.GetAxis("Vertical") * speed * Time.deltaTime));
		if(Input.GetMouseButtonDown(0)){
            GetComponent(NetworkView).RPC("shoot", RPCMode.All);
    	}
	} else {
		enabled = false;
	}
}

@RPC
function shoot () {
	Network.Instantiate(bulletPrefab, transform.position, Quaternion.identity, 0);
    /*if (shotSound) audio.PlayOneShot(shotSound); // play the shot sound
    var hit: RaycastHit;
    if (Physics.Raycast(transform.position, transform.forward, hit))
	{
        // prepare rotation to instantiate blood or sparks
        var rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
        if (hit.transform.tag == "Player"){ // if enemy hit...
            if (bloodPrefab) Instantiate(bloodPrefab, hit.point, rot); // make it bleed...
            //hit.transform.SendMessage("ApplyDamage", 5, SendMessageOptions.DontRequireReceiver); // and consume its health
            hit.transform.networkView.RPC("ApplyDamage", RPCMode.All, 5);  
        } else { // otherwise emit sparks at the hit point
            if (sparksPrefab) Instantiate(sparksPrefab, hit.point, rot);
        }
    }*/
}<commit_msg>improved code a little for networking<commit_after>﻿var speed: int = 5;
var gravity = 5;
private var cc: CharacterController;

var bulletPrefab:GameObject;

function Start() {
	cc = GetComponent(CharacterController);
}

function Update(){
	if (GetComponent(NetworkView).isMine) {
		cc.Move(Vector3(Input.GetAxis("Horizontal") * speed * Time.deltaTime, -gravity * Time.deltaTime, Input.GetAxis("Vertical") * speed * Time.deltaTime));
		if(Input.GetMouseButtonDown(0)){
            GetComponent(NetworkView).RPC("shoot", RPCMode.All);
    	}
	} else {
		enabled = false;
	}
}

@RPC
function shoot () {
	if (GetComponent(NetworkView).isMine) {
		Network.Instantiate(bulletPrefab, transform.position + Vector3(0,1.5,0), Quaternion.identity, 0);
	}
}
{'fraction_non_alphanumeric': 0.13644605621033545, 'fraction_numerical': 0.008159564823209429, 'mean_word_length': 3.8719646799116996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '680', 'n_tokens_mistral': 716, 'n_tokens_neox': 679, 'n_words': 154}