- Home /
Instantiate Error
Hello Guys!
I finished the Minions Healthbars and now want to spawn some minions with Instantiate.
When i drag and drop the prefab i use for instatiating all works perfectly but when the script Instantiates the Health Bar is only Black. I checked all Health Values and they are fine. I have attached a screen with the upper one is that one i have drag and dropped into the world (working) and the below is that one what was created with Instantiate (not working properly)
The Healthbar it self is a GUITexture and the script for attaching it to the game object is:
var target : Transform;
var offset:Vector3;
function Update ()
{
var wantedPos = Camera.main.WorldToViewportPoint (target.position+offset);
transform.position = wantedPos;
}var target : Transform;
var offset:Vector3;
function Update ()
{
var wantedPos = Camera.main.WorldToViewportPoint (target.position+offset);
transform.position = wantedPos;
}
Hope anyone can help :)
have you checked you main prefab with all component and textures attached correctly, then hit the Apply button to it. Doing this will carry out the changes through out any prefabs you have in your scene (im co$$anonymous$$g from the angle that it may be as simple as not carrying your last couple of changes through to your actual prefab but rather an instance where you havent applied that change in your inspector tab to the prefab ) Sorry, if thats no help dude. PS why do you have 2 Updates ? Interesting ! Gruffy
Yeah i have already applied it and checked all variables. Does anyone else know the answer? :/
Can you post the script that defines the health bar? Your code here is just the position of it.
How do you define the healthbar? How do you calculate the length and color?