Moonzel / Godot-PerfBullets

This plugin uses the MultiMeshInstance2D to render thousands of bullets easily while running the logic in C++ to run at maximum performance.
MIT License
360 stars 8 forks source link

I don't understand the bullet_hit signal #16

Open Flux0-0-dev opened 2 months ago

Flux0-0-dev commented 2 months ago

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 commented 2 months ago

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.