Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I don't understand the bullet_hit signal #16

Open
Flux0-0-dev opened this issue Aug 19, 2024 · 1 comment
Open

I don't understand the bullet_hit signal #16

Flux0-0-dev opened this issue Aug 19, 2024 · 1 comment

Comments

@Flux0-0-dev
Copy link

I want to deal damage to the player when the player touch a bullet but I didn't Understand how the bullet_hit signal work
should I use result ?
how do I even use result I didn't understand that in the documents

@Disar
Copy link

Disar commented Aug 24, 2024

Here is how I use it, nothing final but I think this is how it's suppose to work?

result contains all the objects that got hit. r.collider is the actual object we collided with, Area2D in this case. Area2D is a node in my enemy scene, I then use it to get the node I want to operate on. In my implementation Damageable is a node I attached to my enemy scene.

func _on_spawner_bullet_hit(result: Array, bulletIndex: int, spawner: Spawner) -> void:
	for r in result:
		var damagable:Damageable = r.collider.get_parent().get_node("Damageable");
		if damagable != null:
			damagable.takeDamage(10);

Input from the dev would be nice though because I'm not entirely sure if this it the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants