I have the code if (snowman.EnemyHealth.dead == true) and it gives me the error
What is “snowman”? Sounds like you declared it wrong.
its var snowman = Transform;
Your trying to access the enemyhealth var of transform then, which does not exist. You probably want to use getcomponent to get whatever script you declared that var in.
that didnt work either
You’ll need to show us more of the script then.
ok, here it is:
var snowman = Transform;
var sphere = boolean;
function Update () {
if (snowman.GetComponent(EnemyHealth).dead == true) {
gameObject.AddComponent("Rigidbody");
if (sphere == true) {
gameObject.AddComponent("Sphere Collider");
}
else if (sphere == false) {
gameObject.AddComponent("Capsule Collider");
}
}
}
So EnemyHealth is a script, that has a var dead : boolean, right? Can you show that script too?
var health = 1.0;
var hitsound : AudioClip;
var number = 10.0;
var spheres : GameObject[];
var cylinders : GameObject[];
var dead = false;
function ApplyDamage (damage : float) {
health -= damage;
SendMessage("CheckHealth");
}
function CheckHealth () {
if (health <= 0) {
dead = true;
if (hitsound)
AudioSource.PlayClipAtPoint(hitsound, transform.position);
}
}
function OnGUI () {
GUI.Box (Rect (10,number,150,30), "Enemy health " + (health));
}
I dunno man, I just tested your code and it worked for me. Did you forget to drag the snowman gameobject to “var snowman = Transform;” in the inspector?
I cant, because its giving me an error
What error?
that one
You aren’t declaring your variables properly. You have:
var snowman = Transform;
var sphere = boolean;
Which is just attaching the TYPE itself (the type “Boolean”, or the type “Transform”). I think instead you wanted these to be OF that type and have some instance of that type assigned to it:
var snowman : Transform;
var sphere : boolean;
EDIT: In other words, what you’ve done is assigned to “snowman” an instance of System.Type (Type Class (System) | Microsoft Learn) that represents the Transform type. This is a specialized object that lets you gather information about Transforms in general (for example, it can give you a list of all the functions that Transforms have)
aw, damn. I keep on doing that!!! thanks, I keep on forgetting about that.
hello
how to solve this error
Error for
BCE0019: ‘position’ is not a member of ‘System.Type’.
Switch to C#. Type your variables properly. And post code examples when asking for help.
ok thnx yar