Demo videos are here...
Posted by Aardvajk, 04 May 2014 · 330 views
Installed CamStudio and messed about getting it working, then jumped through various hoops to access YouTube. Seems I can't access my old (pre-Google-acquisition) account because the email address I used is the same as a Google account. Nice one guys. We also use gmail at work so I'm having to switch accounts. Grumble grumble.
Anyhoo, video showing everything in action.
Just implemented the whole "not walking off edges when walking" thing. Interesting problem, sort of like reverse collision detection in a way. The approach I've taken is to just detect when the floor is invalid but the previous floor was valid, then just do a closest point to segment check against each edge of the previous face you were standing on to get the corrected position to stop you falling off.
It's okay, but need to figure out some kind of margin system as this just locks the centre of the capsule to the edge, which is physically right but looks wrong as one foot dangles over the edge. Need to arrange things so you stay within a margin, and if you run beyond the margin you are shunted off the edge, so you can't ever start walking outside the margin (to avoid you snapping back in) if you see what I mean.
Ho hum, one for later anyway. Jumping is all working as it should be now.
Just want to brainstorm some thoughts here. Casting a single ray down from the base of the capsule has worked okay-ish up to now but the edge-walking has exposed some problems with this.
What I'm wondering about is if the floor raycast should actually be a small bundle of rays in a circle. Can do this quite efficiently as the rays have a very small maximum length and an AABB pass is done first so 99% of the time all the rays will be casting into the same shape.
I'm thinking that if any of the rays don't hit a floor, I can examine all the rays and get a direction to shunt the player so he falls of the edge if he gets too close, and somehow use this information to keep him a margin back from the edge when edge-walking, so you don't get this whole "one foot hanging in space issue".
My collision detection is not sophisticated enough to get TOI on a cylinder shape, which would be a better way to do it, but a small bundle of, say, 8 rays arranged in a circle might allow me get a workable system for dealing with standing right on edges better. Hmm, One to ponder overnight and attempt in the morning.
Thanks for reading. This bit was more for me than my readers but your interest is appreciated anyway