TransWikia.com

How do you detect a player dying in Rec Room?

Arqade Asked on April 4, 2021

I have a room where people can kill each other by shooting. But people can also die from other causes, such as falling into a pit, running out of oxygen, being attacked by an NPC etc.

Now I want to know that a player died and which player died, to be able to react somehow, maybe trigger an event or count deaths. How do I do this?

One Answer

When a player dies, they get assigned the default role Eliminated. This is synonymous with them having 0 health. The role is removed as soon as their health becomes positive again and they gain the role as soon as their health goes to 0. As such, one way to detect the elimination of a player is to use the Role Changed chip.

You can find the Role Changed chip in the configuration menu for the Role Mapper chip. This chip will listen and fire whenever there is a change to any role in the room, and returns the player ID from the output pin. You can then use the Get Player Stat chip to check if the player's health is 0 when their role changes and this will tell you if they have the Eliminated role.

Caveat 1

There's no good way to filter the Role Changed chip such that it only fires for Eliminated role changes. Instead, it fires for any change to any roles. As such, if an eliminated player also has other role changes happen while they're eliminated, you'll encounter multiple signals with their player ID emitted from this chip. Depending on how you design your circuit, this can cause your logic to be run more times than you want. If you want to run your Eliminated logic only once, you'll need to keep track of if it has been run for a player by using either another role or a flag stored in a player stat.

Caveat 2

The Role Changed chip only has a buffer of 20 signals, so it can be very easy to saturate it especially if you do a role change of everyone in the room. If the Role Changed chip get saturated, then it's possible that it will miss some eliminated events.

Correct answer by Echoleta on April 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP