Event fired with paramters for the function

Hello,
I just started with playcanvas.
And i cant figure out how i can parse a number within the event, for example on trigger enter i fire a event and the player needs to take damage but for future development i would like to tell in the trigger how much damage the player actually gets

so if i have 2 enemy types i just can parse diffrent numbers.

Hi @IlAce and welcome,

Check this manual page, it describes how to communicate between your script instances, directly and using events.

https://developer.playcanvas.com/en/user-manual/scripting/communication/

For events specifically you can pass multiple parameters and receive them on the listener:

// broadcast an event
this.app.fire('score', 10, this.entity.name);
// listen to event
this.app.on('score', function(score, playerName){

}, this);
1 Like

ty @Leonidas im trying to make this work :slight_smile:

@Leonidas it worked out perfectly thank you for you help, can i ask you another question or should i open a new topic?

If it’s related to the topic title feel free to ask it here, otherwise better open a new topic. That helps keep everything organized and searchable.

1 Like