|
|
|
|
Reply From: |
Santiago |
Hi, I’m kinda new to godot but I’d like to help.
You could use a Sprite3D, set it as a child of your rigid body, and set the material of the sprite to billboard, then in material override - material flags you may need to turn on certain flags like “on top”, “unshaded” and “invert faces”; “on top” will render the Sprite3D over everything else, “unshaded” for ignoring light sources and “invert faces” may be needed if the normal is pointing backwards.
The key element is Billboard flag on your Sprite3D-Geometry Instance-Geometry settings in the inspector.
Other thing: I don’t really know why but you have to set textures both on your Sprite3D and it’s Material override diffuse, don’t know why but it seems to not render at all if I don’t set textures on both.
[EDIT]
this is the code for your health bar script
extends Sprite
func _ready():
set_process(true)
func _process(delta):
var parent = get_node("../Node2D") # put here your player's node path
var offset = Vector2(0, -100) # simple offset for the health bar,
self.set_pos(parent.get_pos()+offset)
just make sure your health bar is a brother node of your player node
Sounds interesting, but I’m trying to work in 2D with progress bars. Would using 3D somehow disable rotation?
jarlowrey | 2017-06-01 14:34
I’m really sorry, Don’t know how but I thought you were working on 3d.
In that case you would parent the health bar to the player’s parent, to make it a brother node let’s say, and put this script on the health bar:
extends Sprite
func _ready():
set_process(true)
func _process(delta):
var parent = get_node("../Node2D") # put here your player's node path
var offset = Vector2(0, -100) # simple offset for the health bar,
self.set_pos(parent.get_pos()+offset)
I’m assuming your health bar is a simple 2d sprite, and in that case, you can set the offset from the inspector, if it’s a node2D you can use the offset from the script.
Hope this helps, and sorry for my misunderstanding
Santiago | 2017-06-02 11:48