what's wrong with this script =/


public class Personagem {

private var nome:String;

private var vida:float;

private var vidamax:float;

private var resistencia:float;

private var resistenciamax:float;

private var armaprincipal:int;

private var armareserva:int;

private var municaoprincipal:int;

private var municaoreserva:int;

private var animacao:int;

private var pers: Transform;

function Personagem(nome:String, pers:Transform, vida:float, vidamax:float, resistencia:float, resistenciamax:float, armaprincipal:int, armareserva:int, municaoprincipal:int, municaoreserva:int) {

	this.nome = nome;
	this.pers = pers;
	this.vida = vida;
	this.vidamax = vidamax;
	this.resistencia = resistencia;
	this.resistenciamax = resistenciamax;
	this.armaprincipal = armaprincipal;
	this.armareserva = armareserva;
	this.municaoprincipal = municaoprincipal;
	this.municaoreserva = municaoreserva;


function andarFrente() {

	pers.rigidbody.velocity = pers.transform.forward * 4;



var jog: Transform;

var jogador = new Personagem("Felipe", jog, 100.0, 100.0, 100.0, 100.0, 101, 201, 100, 100);

function Update() {



The var jog is the GameObject that have the Player script. When i run the game unity give me this error “Null reference expection”

if “var jog : Transform” is used for the transform of the object that it is attached to, you forgot to assign it in awake() or start() , the way it looks up there is that it’s just an empty variable meant to hold a transform.

var jog : Transform ;
var jogador : whatever ;

function Start(){
  jog = transform ; // now jog has a value, the attached transform
  jogador = whatever // after jog is assigned, now jogador can make something with it

Thanks worked ^^