Colliders Everywhere
Somehow this became the best solution to jumping, along with other pleasant surprises. While I was solving the problem of jumping, I couldn’t get a working solution of getting the zoid to jump only when it is on the ground, which resulted in my previous solution ( the code is so hideous that I deleted it about six months ago :P) of recording the height when the zoid leaves the ground.
Of course, that was so wrong that I wrote more and more hacks to cover it up, until it all blew and the zoid still won’t jump up a cliff normally. So I went and think what happens when the zoid jumps.
- The zoid checks if it’s on the ground.
- The zoid applies force from it’s legs upwards.
- The zoid comes back down on the ground.
So that’s when I thought, we need to know if the zoid is on the ground! First I tried using the mesh collider generator to create a collider for the whole body, then wrote a script to check if the zoid collides with something tagged terrain… It failed when the zoid tried to jump from something that was not a terrain element. Tagging everything with terrain is insane. What about other zoids? Then I thought that the constant collider in the question was the zoid. So I changed the script to check for the zoid…and that sounded stupid, so that means if the zoid hits anything it can jump?
That left me to do what you saw in the picture, adding colliders first for the legs, then extending that idea to the whole body. I tagged the legs with the colliders and changed the scripts again, resulting in this script. I’m still thinking how to make it into a function so all the repeated code can be removed, though.
Edit: the old script Check_on_the_ground was deleted as um, there was completely no need for it’s existence.