How can I detect if a player is near a wall?

I have a shooting game and I want the viewmodel to animate when the player approaches and looks at a wall. I want them to tell me how to do it. I don’t need a code. Thanks so much for reading
edit: if you could tell me several ways to do it I would appreciate it, (third person also if you can) but only local

1 Like

You can try using Magnitude and RayCast.

Would I do it in a run service or how?

1 Like

Use a local script for checks during every RenderStep for the distance between the player and that wall.

You can check the distance by getting the Player Character’s position and subtracting the wall’s position from it, then using Magnitude like Alex had mentioned.

Once the player is close enough, you can set during the RenderStep loop to call a function that animated the viewmodel.

Magnitudes and Raycasts, add checks if the raycast exists so it works, and use magnitude to check if it’s near

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.