Jumping off Walls
I got up to learning more 2D platforming this week, though with a friend of 20+ years in town this week I’ve ended up doing far more touristy stuff this week than bi’ness. Actually, 2D platforming is a slight misnomer, as the stuff that I was working with this week was actually 3D.
I tried to trouble shoot some of the problems that I was having last week, and it seems that the issue that I was having in regards to the animation switching into the jump pose while standing on the corner was related to a couple of things.
What I had should be working, except it seems that there must be some floating point precision issues going on. I was very careful to have my ground check (which was being done by using Physics2D.OverlapCircle() to check a radius around a given point for a ground surface) positioned and sized correctly, however it just wasn’t working. As best as I can tell there’s a floating point accuracy issue at fault here because turning Pixel Snap on or off made no difference however if I set my groundRadius to 0.0005 larger than it needs to be, the problem went away.
Aside from that , it’s been suggested that I avoid using the OverlapCircle function and instead use a LineCast. I had briefly seen line-casts in use in one of the tutorials, last week however it was already set-up and didn’t require me to do any tinkering. What’s been recommended, is that I use line-casts for detecting different types of surfaces using layer masks. This will make it easier to a: detect edges, and b: detect slopes… apparently using Edge colliders is going to be better than Box colliders. This is the theory at least. I still need to test it.
The line casting looks promising though as that’s what allowed Sonic to have different off-balance animations depending on how close he was to standing on an edge. Pair a multi-ray cast check with something to make sure that you’re actually standing still, and you should be able to have a nice set-up.
The tutorials that I went with this week were the Sidescroller Platform videos from Sebastian Lague’s YouTube channel. These videos go a bit further than the stuff I did previously, and also makes use of 3D models and rigs rather than 2D and sprites.
- We are using ray casting this time around… however I’m going to have to tinker with it to get results similar to what I discussed above. The two main problems that it’s got at the moment is that I’m changing the size of the collisions depending on whether the character is sliding or standing – this results in bad collisions if the character stands up from a sliding position but has something above his head. The character also seems to be configured to better accept diagonal collisions, yet falls through slanted surfaces. That’s a puzzle to me. I’m going to have to find some info out there about colliding surfaces, unless I want to be stuck in 8-Bit platformer world forever.
- We also build our own physics rather than relying on Unity’s. I’m not really sure what the benefit is of this.
- We have the player instantiated by the camera. The series also includes a little about rag dolls, and killing characters so we’re generally passing information around between different things a lot more than in other tutorials I’ve followed.
- We have a model (from Blender) which is pre-animated and so we’re bringing it in and using the animation tools to blend between the different states. One thing that’s annoying about this is that I have no idea how to use Blender, and this is kind of glossed over… so I’m not quite sure how to set up the exports myself just yet. Unfortunately Sebastian updates the model/rig a couple of times through the series, and by the time we get to discussing rag dolls, I’m not entirely sure how to get the rig switched so that it works. I had to just open his final file since I couldn’t get the new rig to work in my old file.
- We do learn how to have some animations blended together (the character’s headband animates at all times and is an animation that is masked in).
- We set up a death trigger which sends the character into the rag doll state
- We set up wall jump mechanics
- Finally, we create checkpoints and allow for the completion of levels.
Sebastian finishes the 8th video by stating that there will be a 9th… but given that he’s moved on and started teaching other game mechanics, I suspect that’s going to be it for his sidescroller tutorials. They’re good, but also a little vague. They’re a little tougher to pick stuff up from than previous things I’ve done.
I still have the same list of “to-do” tutorials as I had last week, however I’m also very interested in checking out the 2D Tool Kit from the asset store. It seems like it’s geared a little more specifically toward the type of stuff I want to start making than the new tools developed by Unity for 4.3.
Egad there’s a lot to learn!