This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

For my enemy code:
var maxhp= 10
var current
currenthp= maxhp
Func Onhit(damage):
currenthp -=damage
If current
hp <=0

My player code:
var damage
Func Area2dbodyentered(body):
If body.isingroup("enemies")
Func physicsprocess(delta):
If event.Input.isactionjust_pressed("melee"):

The end result is that the first damage is only counted like 10-5 = 5 and the current_hp will always stay on 5

in Engine by (29 points)

I have a question about this method you use, can you enlighten me how exactly you communicated the damage from the player to the enemy?
You only used a signal to check in the body entered the area... and a group for checking if the body was the enemy... did the body.onHit go through the group?
I didn't get that part.

1 Answer

0 votes

I just need to put currenthp=maxhp in func _ready()

by (29 points)
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.