I need to find a way to detect if a player is behind a wall. I wanted to use raycasting but it can only returns the baseparts and the player is only compose of meshparts and the only basepart is the humanoidrootpart that it can only get at certain angles. Any help?
Could you explain maybe the use case more, because if there a wall on all sides of the player I would imagine it would be very difficult to check if its coming from the player themselves, is this for some enemy AI?
Yes it’s for an AI.
Imgur: The magic of the Internet
I want to make it so that when the player is on the other side of the wall, the NPC to stop shotting
Make a raycast from the AI to the player, see if it intersects anything named Wall or what you have your walls named, you’d do this in a loop
If you subract where the AI is from where the player is this will give you a vector in the direction of the player, you can use this in your raycast and any position the player is at the NPC can detect no matter what angle
Might not help for what you are trying to achieve, but just FYI
This is untrue: BasePart comprises all Part related classes, including Part and MeshPart classes. Most, if not, all body parts in a character are considered a BasePart.
Even if raycasting was unable to detect meshparts, wouldn’t you be raycasting from the player to the wall/other object anyway?