Hello World! ![]()
For learning purposes, I’ve just finished putting together my own character controller from scratch, both First and Third person perspectives, and learned a lot about vectors and rotations and local vs world space, but a lot of it still remains a mystery to me that I plan on remedying over time. A big problem I’m facing right now is trying to implement cover (as in using an object in the world as cover), which in my test scene is just a 3D Cube. In order to implement this I need to find the bounds (topLeft, topRight, botLeft, botRight in world space) of the side of the cube I’m facing, so I raycast to it, got the collider info, and found that I can’t just get the side I want, I have to deal with the entire cube, and I find myself way over my head having to deal with AABB issues, and the nightmare gets worse if the cube is rotated. I abandoned this approach and decided on another strategy; I’ll raycast it to death and find the horizontal bounds, which is all I really need.
As you can see in the picture below, the plan is to raycast to the wall, get the normal, and use the normal to give me a bunch of points perpendicular to the front of the wall that I can use to raycast back at the wall to find its horizontal bounds. Each orange point is a point in space that is 1 meter in front of the wall, and I keep iterating over these points, raycasting back against the wall, until the raycast no longer hits the wall; at the point I have a rough idea of the horizontal bounds of that wall, which I can get more precise with more granular raycasts if I’m so inclined. The problem I’m having is coming up with those points in the first place! I’m able to get the initial point by using the hit.point and (negative) hit.normal, which you can see is the green raycast cast back against the cube, but I’m lost as to how to generate more points (the orange ones) relative to the wall.
Help me Obi Wan Kenobi… you’re my only hope!
