I’d like to make an option to “press E” to pop up on a 2d screen when A: getting within a certain range of an entity as well as B: looking directly at the entity. Once this is done, I’d like to make the entity a child of the player’s camera, and when they press E again on a specific target entity, x happens.
The project is here: PlayCanvas | HTML5 Game Engine
The entity in question is named “pickableEnt”
The entity I would like for it to interact with (after picking it up) is named “targetEnt”
That does help!
My only issue though is that I’m trying to make it so that it can only be triggered when you’re within a certain distance (it’s a first person project). Do you have any advice on this?
You need to debug your script to see which part is running correctly and which part is not. You can add for example some console.log('check 1'); to do this. Open the console of your browser with F12 to see the logs.
The laptop I am using doesn’t have an F12, only F1 through F10, is there any alternative keybind?
Edit: Nevermind I looked it up and there’s some obscure way to do it.
Edit edit: Turns out that didn’t work.
So when I did that, nothing happened, I went back and just to see what would happen, I changed pickableDistance on line 26 back to farClip, and it seems to work now. Only issue is, now there’s no maximum distance from where you can pick it up.