So im using a points package i found on the asset store, BUT i have a issue. its setup all wierd…
heres what they give me,
var Point : float;
private var GetHitEffect : float;
private var targY : float;
private var PointPosition : Vector3;
var PointSkin : GUISkin;
var PointSkinShadow : GUISkin;
function Start() {
Point = Point;
PointPosition = transform.position + Vector3(-1,-10);
targY = Screen.height /2;
}
function OnGUI() {
var screenPos2 : Vector3 = Camera.main.camera.WorldToScreenPoint (PointPosition);
GetHitEffect += Time.deltaTime*30;
GUI.color = new Color (1.0f,1.0f,1.0f,1.0f - (GetHitEffect - 50) / 7);
GUI.skin = PointSkinShadow;
GUI.Label (Rect (screenPos2.x+8 , targY-2, 80, 70), "+" + Point.ToString());
GUI.skin = PointSkin;
GUI.Label (Rect (screenPos2.x+10 , targY, 120, 120), "+" + Point.ToString());
}
function Update() {
targY -= Time.deltaTime*250;
}
along with this “Help” ducument
Hello,
function MonsterDied() {
var PointScript = AddComponent("Point");
PointScript.Point = 50;
}
When MonsterDied() function is triggered, 50 points will be seen on the object.
i have a point and click game that uses raycast and whatnot to collide with a cube and blow it up. joy simple stuff runs awesome. I cleaned up the initial code they gave me so it dosnt return random values annnd it works fine. returns a constant.
BUT
adding the function then calling
MonsterDied(); isnt working. heres the code im trying to implement it into,
//Enemy script
//Inspector variables
var numberOfClicks : int = 1;
var respawnWaitTime : float = 2.0;
var shapeColor : Color[];
var explosion : Transform;
var enemyPoint : int = 100;
//Private variables
private var storeClicks : int =0;
function MonsterDied() {
var PointScript = AddComponent("Point");
PointScript.Point = 50;
}
function Start()
{
storeclicks = numberOfClicks;
var startPosition = Vector3(Random.Range(-6,6),Random.Range(-4,4),0);
transform.position = startPosition;
RandomColor();
}
function Update ()
{
if(numberOfClicks <=0)
{
if (explosion)
{
MonsterDied();
Instantiate(explosion, transform.position, transform.rotation);
}
var position = Vector3(Random.Range(-6,6),Random.Range(-4,4),0);
RespawnWaitTime();
transform.position = position;
numberOfClicks = 1;
}
}
function RespawnWaitTime()
{
renderer.enabled = false;
RandomColor();
yield WaitForSeconds(respawnWaitTime);
renderer.enabled = true;
}
function RandomColor()
{
if(shapeColor.length >0)
{
var newColor = Random.Range(0,shapeColor.length);
renderer.material.color = shapeColor[newColor];
}
}
But no matter what i do or where i put it i always get the "Unknown Identifier: ‘AddComponent’. error.
i know this is something probably super simple but i’ve been digging through the API for 2 hours and i cant find a solution. i even tried switching it to GetComponent but alas no luck. any help guys?