Raycast ignores entities with rigidbody and collision components?

I have successfully completed the token spawning functionality of ETA. Thanks to yaustar for the help!

Now I have another problem. I want my users to be able to click a token once it is spawned, and then be able to click a tile to move that token to that tile. Before that can happen, the tokens must have rigid bodies and collision components, so that the raycast can select them. The relevant script is here (lines 162-287). But as you can see, once a token is spawned (bottom-left button to open menu, then select a token, then click Spawn Token, then click a tile), any further raycasts will simply go straight through the token, ignoring it and hitting the tile below it. This would make selecting the token impossible.

Can anyone help me see what I might have done wrong? The script for making the collision and rigid body components is on lines 178-179, lines 208-209, lines 237-238, and lines 266-267.

Having seen the code but at a guess, ensure that you are setting the position of any entity with a rigidbody via teleport https://developer.playcanvas.com/en/api/pc.RigidBodyComponent.html#teleport

(Just don’t use this to move a rigidbody gradually between positions every frame).

1 Like