So I’m working on a control system for my characters. I want to it to be lightweight enough to allow quite a few characters on-screen on mobile devices if possible. But I don’t really know anything about how heavy raycasting in the physics engine is.
It appears I will probably need an approach similar to what I’ve seen in old-school Sonic games; to use raycasts (pixel sensors in the old games) at a few spots to determine how even the ground is, surrounding the character in a cylindrical fashion. This would sense whether the coming surface was high enough to step over, even enough to stay grounded, or if the coming surface is a ledge. Currently I have only one raycast straight down, using some trig to determine grounding, and getting the ground normal.
One more raycast in the movement direction shouldn’t hurt. But the problem is that when running parallel enough to an uneven surface, one straight ahead won’t catch it since it’s on the side. But to catch that properly, I would probably need to make an arc with them; placing them at 45 degree angles from each other.
And what of any surfaces behind the character that I have to detect? In all, this would bring me up to 8 raycasts; cardinal and diagonal directions, in order to have full detection. And that doesn’t even include the one to detect pushable objects.
My question is… am I becoming unreasonable? Am I just looking at this from the wrong angle, or do people tend to use this many? Does anyone see some way I can make this smarter?