Raycast problem

Hi!

I started working on FPS Car Mechanic Game, but I don’t know how to solve, that I can mount parts to the car engine with mouse, when in right place we can mount part with left click and set child as empty gameobject (empty gameobject = part placeholder). On right click take out part from the engine and set as ItemSlot child. My problem is Raycast collide in Engine block part and not in the Piston. (if piston in the cylinder)
How could solve this problem ?

Thank you very much!

Have you got any code to show us? You’ll likely get a lot more help.

…and ensure you stick them in the code tags!

can use layermask, so only shoot ray on the objects on that given layer

or raycastall, to get list of everything it hits, then compare with tag or some other value,

Yes, I have a code for mount item, but I found a solution.The raycast don’t collide with piston,because the engine block mesh collider is convex with rigidbody (cube,with no holes), but on the asset store I found THIS script and if the engine block have a normal mesh collider (with holes/cylinders), then the raycast will collide the piston collider.I hope it was understandable, because my english is not perfect. :slight_smile: