How to allow a player to pickup a different gun or heals

how would i make a function that allows a player to pick up a gun from the ground or heals?
for example, a gun would be on the ground, the player would walk up to it and press e, and it would equip that new gun. or for heals, a player would walk up to it and press e, and it would use the heal, healing the player.

For keyboard events you can check this tutorial out:
https://developer.playcanvas.com/en/tutorials/keyboard-input/

To collect the gun, you can check the distance between the player and the gun, and if the player presses E, and the distance is below some threshold, you can disable the gun on the ground and enable the gun within the player entity, same can be done for healing, but healing would just change the number on the UI

2 Likes

ok
thanks!

thanks! my new script is almost working!

1 Like