0 votes

My intend is to make glass shadow effects for the player hearts (health) whenever they go from full to empty, which are exactly like this video https://www.youtube.com/watch?v=JU2jaVewfxY&t=46s

I have no problem recreating the particles2D, but as a beginner, I have no ideas how to apply it into code. Sorry about the vague, maybe the codes could summary my ideas better:

healthUI node:

extends Control

var hearts = 5 setget set_hearts
var max_hearts = 5 setget set_max_hearts

onready var heartUIfull = $HeartUifull
onready var heartUIempty = $HeartUIempty

func set_hearts(value):
 hearts = clamp(value, 0, max_hearts)
 if heartUIfull != null:
    heartUIfull.rect_size.x = hearts * 25

func set_max_hearts(value):
 max_hearts = max(value, 1)
 self.hearts = min(hearts, max_hearts)
 if heartUIempty != null:
    heartUIempty.rect_size.x = hearts * 25

func _ready():
 self.max_hearts = PlayerStart.max_health
 self.hearts = PlayerStart.health
 PlayerStart.connect("health_changed", self, "set_hearts")
 PlayerStart.connect("max_health_changed", self, "set_max_hearts")

the healthUI node is also has child are shardBig and shardSmall like the video ahead and connecting with the PlayerStart (PlayerStats but I spelled it wrong), which is an autoload:

extends Node2D

export(int) var max_health = 20 setget set_max_health
var health = max_health setget set_health

signal no_health
signal health_changed(value)
signal max_health_changed(value)

func set_max_health(value):
 max_health = value
 self.health = min(health, max_health)
 emit_signal("max_health_changed", max_health)

func set_health(value):
 health = value
 emit_signal("health_changed", health)
 if health <= 0:

func _ready():
self.health = max_health

You guys probably familiar with this, in case you don't, those are the exact same codes in HeartBeast, Player Hearts UI video (https://www.youtube.com/watch?v=7A4EPIr-6Sc&list=PL9FzW-m48fn2SlrW0KoLT4n5egNdX-W9a&index=18) which works just great, but like I said, I have no ideas how to make the particles emmiting and show up at the right position whenever the hearts turn from full to empty, it would be great if anybody have any ideas, thanks for the help and sorry for my bad English.

Godot version godot 3.3
in Engine by (56 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.