Help with collectables

can someone help me detect when the player is touching an enitty and if they are it checks if they are pressing a key then destroy it

Hi @Kayden_Dougherty ,

You can use collisions and triggers to detect when that happens, here is a good tutorial:

https://developer.playcanvas.com/en/tutorials/collision-and-triggers/

And instead of playing a sound as the tutorial does, you can call entity.destroy() to remove the item, if the player entered the item and is pressing a key.

thanks
but it wont destroy when i hit e but thats fine

You can add the following line in your trigger enter callback:

entity.destroy();

A post was split to a new topic: My script doesn’t work