Thursday, September 15, 2022
HomeGame Developmentgodot - Need assistance with customized well being part

godot – Need assistance with customized well being part


I made well being property as part, so any object with that property could be broken.

extends Node

class_name Well being, 'res://property/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(harm = 0):
    self.well being -= harm
    if well being <= 0:
        self.entity.on_0_health()

However the issue is that it doesn’t matter what I am assault, the one one entity obtain all of the harm.

I am positive it is downside as regards to part, however cannot repair it.

replace:
The log says that all of them completely different nodes

goal:Goal:[StaticBody2D:29762782407]
me:Well being:[Node:29779559624]
goal:Target2:[StaticBody2D:30651974908]
me:Well being:[Node:30668752125]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments