[ad_1]
I made well being property as part, so any object with that property could be broken.
extends Node
class_name Health, 'res://belongings/icons/health_ico.png'
var entity
var stats_name
var init_health = 4
var well being = init_health
func _init():
self.stats_name="well being"
func _ready():
entity = get_parent()
self.entity.stats[self.stats_name] = self
print('goal:' + str(entity))
print('me:' + str(self))
func apply_damage(injury = 0):
self.well being -= injury
if well being <= 0:
self.entity.on_0_health()
But the issue is that it doesn’t matter what I’m assault, the one one entity obtain all of the injury.
I’m certain it is drawback on the subject of part, however cannot repair it.
replace:
The log says that all of them totally different nodes
goal:Target:[StaticBody2D:29762782407]
me:Health:[Node:29779559624]
goal:Target2:[StaticBody2D:30651974908]
me:Health:[Node:30668752125]
[ad_2]