Ways to create walls without using rigidbody physics in 3D,Ways to limit a player's movement without rigidbody physics in

Hi, I am currently making a top-down 3D bullet hell (inspired by the 9S hacking minigames in Nier:Automata) and my player uses controller input to move around using transform.position. All of my movement scripts work how I want them to. My issue is that due to the nature of transform.position, collision isn’t as straightforward as I’d like it to be. I simply want to be able to create walls that will stop the player when they attempt to move towards them. I want to know what my options are, and if there may just be something I’m missing. I’d like to use raycasts, but I’m unsure how to limit the player’s movement once the raycast hits one of my walls, as setting the player’s position to hit.point will simply allow them to walk through the wall after they hit it the first time. Any help would be greatly appreciated, thanks.,

It seems like you’re mostly there, and you have a couple options

A) Stop the player from moving entirely if the raycast hits a wall. This will stop the player from moving into the wall, but unfortunately will also mean they cannot slide against the wall. Note that the ray needs to be cast before the player moves so that you can cancel their movement, rather than forcing them to go to a specific position.

B) If your walls are straight, then you can figure out basically a line that represents the wall. When the raycast detects the wall, you can halt any movement the player has perpendicular to the wall.


This should give you a good jumping off point, if it isn’t enough I can brush up on the maths behind option B to help you figure it out.

jjjjjjjjjjjjjjjjjjjjjjjjjjjjj