- Home /
Respawning script question.
I'm my scripts it wont let me access a character at all. For example my small respawning script i plan on building on. Could someone help? But I am looking for a solution to accessing the game object variables which i never have learned. please help me if you can.
var mainCharacterHealth = 100; var dead = false;
class health {
var dead = false;
function spawn ()
{
//if you are dead goto position
if (dead) {
gameObject.transform.position = Vector3(0,8,0);
}
}
function OnControllerColliderHit ( Hit : ControllerColliderHit )
{
//if you hit the designated object you will take 99 damage
if(hit.gameObject.transform)
{mainCharacterHealth -= 99;
}
}
}
Are you trying to access the functions and variables of the newly spawned character object, or the transform details?
Answer by Est · Feb 24, 2011 at 04:48 PM
hi! i am also looking something like you i tell you what i know
to access to the variable in a gameobject you can use the inspector-metod
var target : Transform;
using a script whit this declaration on top ,
select the object with the script you can drag the "target-object" you want move .... on the inspector in the "target",none transform , so you can talk-to him during the script , using the target.
target.transform.Rotate(5,0,0);
if you want make the "link" during the game and not before start you must find it ....
var someone;
someone = GameObject.Find("player");
and then sure......
someone.transform.Rotate(5,0,0);
there are so many way to "find" the object ....
Your answer
Follow this Question
Related Questions
Buff System 1 Answer
How can I make a Transform that I dont have to set each time I place a prefab? 1 Answer
End game then an Object is close to another object? 0 Answers
Sound when see gamect? need help 2 Answers
Finding object via script 1 Answer