Picking up items and floating them in front of the character

Well, it doesn’t give me the error on startup anymore.
Now it gives me the error whenever I try to pick up the item.

So, what is the error?

" Uncaught TypeError : cannot read properties of null (reading ‘collision’) "

That means that this.pickedEntity is still null at that point. Can I see the script?

I couldn’t share the file, so here’s the link:
https://playcanvas.com/editor/code/905650?tabs=80215704,75492412

It’s on line 27 where this.pickedEntity is still null, because you define it on line 30. That means you can use this.pickedEntity only after line 30.

So… I just put it after line 30?

So I set the collision function to do a translateLocal up 0.1 units.
This became a problem extremely quickly.
What else could I do to keep the object from touching any rigid bodies?

The idea was that you stop dragging after collision. Basically all the steps that you do when you release the mouse (else statement, when mouse button is not pressed).

The only problem with that is that the second I pick up an item, it’s already touching the surface it was picked up from, so the collison event is immediately triggered.

Hmm, yes indeed. Hard life. :sweat_smile: