0 votes

I made this game project on godot 3.0.6 and updated it to 3.1.0 and now the HP script doesnt work.

This is a script that i use to extend to my KinematicBody2D characters (Enemies, Player)

extends KinematicBody2D

export var DMG: int
export var MAXHP: int
var HP=MAXHP

var dmg_timer=0

func dmg():
    if dmg_timer>0:
        dmg_timer-=1
    for area in $hitbox.get_overlapping_areas():
        var body=area.get_parent()
        for i in 1:
            if dmg_timer==0:
                HP-=body.get("DMG")
                dmg_timer=10
                print(HP)
            if HP<=0:
                queue_free()

Originally it worked, it got the HP and DMG i set for the characters that extend the script, like 10 for the Player and 5 for the enemy, but now it just get the data from itself and now the only get 0 HP

I dont really know a lot about godot and its scripting so how can i make it so that my script runs normally again. What did they change in scripting for extending scripts.

in Projects by (386 points)

1 Answer

0 votes

Check if You have correct values in editor. From what I see script passes default value for int which is 0 or dont have required reference.

by (180 points)

I use this script and extends it to my character scripts and the i edit the variables i exported of the character scene in script variables i set my play HP to 10 and enemy to 5 but the script isn't getting the HP variable from the scenes only from itself.

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 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 webmaster@godotengine.org with your username.

Categories