Access Method on collision works, but won't accept variable, silly or am I missing something?

GODOT 3.5.3 LTS

this works:

Bullet.gd

if collision:
	if collision.collider and collision.collider.has_method("hit"):
		collision.collider.hit()
		do stuff...
HitEntity.gd

func hit():
	if dead:
		return
	health -= 1
	if health == 0:
		dead = true

but this does not:

	collision.collider.hit(DAMAGE)
func hit(damage):
	if dead:
		return
	var deal_damage = damage
	# health -= 1
	health -= deal_damage
	if health == 0:
		dead = true

is this silly or am I missing something?

Does the method “hit” take in any arguments?

sure I can set it up to take arguments:

func hit(damage):
	if dead:
		return
	var deal_damage = damage
	# health -= 1
	health -= deal_damage
	if health == 0:
		dead = true

wow that was fast response :slightly_smiling_face:

So it was set up to take arguments when you called it without arguments?

no I first set it up to recieve then I sent

So it was set up to take arguments? Then calling it without arguments shouldn’t have worked.

calling the method without arg works fine if it does not recieve any, but if you try to send an arg and change it to recieve it does not work, i.e. the method is still called but arg is not passed.

My goof, too busy to notice:

if health == 0:

works fine, case closed, sorry for wasting precious time :upside_down_face:

if health <= 0:

Have a great day!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.