|
How would i put a gui texture, such as a health bar, over an object. i want it to be able to move around with the object. im unable to find anything that could help me on the scripting reference.
(comments are locked)
|
|
thanks man... this should work, but when i put the code in then a "NullRefenceExeption" keeps popping up in the debugger. any idea why? here is the code that is messing up. it's in javascript. var player_ob : GameObject;
var cam : Camera; var cam_pos : Transform; cam_pos.position = cam.WorldToViewportPoint(player_ob.transform.position); Either you don't have an object in the scene with the name "Swat" or you have no camera with the "Main Camera" tag.
Nov 18 '10 at 07:34 AM
Slem
that is what i figured too, but i do have an object named swat and the only camera that i have on screen at this point is the main camera. i now took out the "cam = Camera.main" part of the code, then drug the "Main Camera" into the variable in the inspector. there are no errors in the debug, but it now won't print out the position in the GUI. the problem is definitely in the "cam_pos.position = cam.WorldToViewportPoint(player_ob.transform.position);" because when i comment that out then it prints everything else just fine.
Nov 18 '10 at 07:48 AM
daviddan2010
(comments are locked)
|
