so i want my npc to simply do all these things: stay still, always look in the player its shootings direction and not shoot through walls. and i heard of something called raycasting but i dont think its what im looking for (correct me if im wrong) but my npc still shoots through walls no matter what. https://create.roblox.com/store/asset/137729063167066/npc-helpp ← here is the model if you want to have a look at it
If the NPC shoots through walls and you want it to stop doing that I actually suggest using raycasting. Raycasting is basically like shooting a projectile/bullet in a direction and then along the way it will return any parts it hits.
So in your case - without having looked at the model, I’m guessing you would have to do a raycast every time a player is within range to shoot and then if there is a successful raycast from the model to the player without any obstructions it can proceed to shoot.
A good video to learn raycasting:
it seems you’re using a “Basepart.Touched” Type of Hitscan for projectiles (the roblox slingshot script), and yeah. its kinda messy (in my experience), Really Suggest you use Raycast instead.
kaizen has already have the video up so i HIGHLY suggest you watch that
thank you i watched the video and it worked!!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.