I followed a tutorial i am sure i have exactly what he had except for the name but i keep getting this error "Assets/Galaxy_Quest/Scripts/s_HUD.js(12,43): BCE0017: The best overload for the method 'UnityEngine.Object.FindObjectOfType(System.Type)' is not compatible with the argument list '(s_mainCharacter)'." here is my code for both files:
*s_mainCharacter*
static var SPEED = 7;
static var TURBO = (SPEED *2);
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
var pHealth : int;
var pScore : int;
var pLife : int;
var pPower : int;
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
// Move forward / backward
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = SPEED * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown("Jump")){
//var bullit = Instantiate(bullitPrefab, GameObject.Find("leftSpawnPoint").transform.position, Quaternion.identity);
var bullit = Instantiate(bullitPrefab, GameObject.Find("rightSpawnPoint").transform.position, Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}
function damageTaken(totalDamage : int){
pHealth -= totalDamage;
if(pHealth <= 0){
if(pLife <=0){
killPlayer();
}
else {
pLife --;
}
}
}
function killPlayer(){
print("YOU DIED");
}
function addScore(totalScore : int){
pScore += totalScore;
}
function getStatus(send : int){
switch (send){
case 1:
return pLife;
break;
case 2:
return pHealth;
break;
case 3:
return pPower;
break;
case 4:
return pScore;
break;
}
}
*s_HUD.js*
private var s_mainCharacter : s_mainCharacter;
var playerLife_pos = Vector2(0,0);
var playerHealth_pos = Vector2(0,0);
var playerPower_pso = Vector2(0,0);
var playerScore_pos = Vector2(0,0);
function Update () {
}
***
//I get error in the Awake function everything else works
***
function Awake(){
s_mainCharacter = FindObjectOfType(s_mainCharacter);
}
function OnGUI(){
var playerLife = s_mainCharacter.getStatus(1);
var playerHealth = s_mainCharacter.getStatus(2);
var playerPower = s_mainCharacter.getStatus(3);
var playerScore = s_mainCharacter.getStatus(4);
GUI.Label(Rect(playerLife_pos.x,playerLife_pos.y,100,100), playerLife.ToString());
GUI.Label(Rect(playerHealth_pos.x,playerHealth_pos.y,100,100), playerHealth.ToString());
GUI.Label(Rect(playerPower_pso.x,playerPower_pso.y,100,100), playerScore.ToString());
GUI.Label(Rect(playerScore_pos.x,playerScore_pos.y,100,100), playerPower.ToString());
}