NokiMo
Megan Fox
Megan Fox

patreon


Animation mirroring for tricks (the dumb way)

(this is last month's a day late, I'll do another later this month, sorry!)

So, this came up recently, because I'm working on grab tricks: https://twitter.com/skatebirb/status/1157001655595855872

The way skateboard tricks work, if you're not aware, is that a board has a nose and a tail. It's hard to see on modern boards, just, trust me, it's there. The tail goes behind you, and the nose in front, and whether that means in front of your left foot or your right foot depends on which foot you like having forward. Standard means left foot is forward, goofy means right foot. With me so far? No? Ok well ignore the stance part and just imagine you drop your board, hop on, your left foot is forward, and ok, you're skating! yay!

Now then, if we're gonna do a nose grab (pretend we're in the air cus you just went up a sick ramp and caught air), we're gonna reach down with our left hand. That's the nose. Tail grab, with our right hand, tail. Easy, right?

Ok but what about when we go back down the ramp and zoom back into the park? Now we're skating toward our right foot instead of our left foot. We're in what is called Switch, and now all our trick movements are backwards. If we catch air and want to do a nose grab, we use our RIGHT arm, and tail grab is our LEFT arm.

As an aside, this is why skating Switch is so hard. Your legs move in a totally different direction, you have to use your off-hand instead of your main (or vice versa), etc, might as well be learning a new trick. This is why skateboarders who can skate in Switch just as well as they can normally are so impressive. Anyways!

This image is of a snowboard but ignore that, the grab names tend to be the same. What you'll notice, hopefully, is that really, a nose VS a tail grab movement is the same, depending on which way you're going, right? So all you gotta do to implement these is animate each once, and then switch the animation for, say, a tail grab, between either grabbing-left or grabbing-right depending on direction of travel at the time. Similarly, if we're skating in Goofy (your right food is forward instead of your left), well REALLY, all we've done is mirror our movements for what is a tail or nose grab again, right?

So that's where the mirroring code comes in. $3+ patrons get the code, but in absolute basic terms, really all I'm doing is this:

My tricks don't know what animation is playing, they just set an animation parameter. Nose grab sets "grab_left", because skating in standard non-switch, you reach down with your left hand. All the tricks work that way, where what I put in is what you'd do to do that trick if you were skating standard non-switch.

Then I just mirror it. Literally. I do a string-replace for "left" and I say "right" instead, or vice versa, if the player is skating Switch.

Then I copy-paste that couple lines (seriously) and run it, AGAIN, for if you're skating in goofy stance. Because it's the same logic. Which means if you're skating Switch goofy, the code mirrors everything twice and you're back to where you started.

Stupid? Extremely. Effective? You betcha.

Why not just mirror animations? Well, first, Unity doesn't really... do, that, and - even if I wanted to, that kind of logic usually only works if you're working with a standardized human IK rig. I have a, uh, birb. So. I'd have to get super custom, and being a complete idiot and doing a string search and replace is waaaay easier.

(I have this giant folder of GIFs from my last job, and wow it has some GIFs)

Anyways, that's how I do animations. I dunno if I've covered board movements yet. I think I did, but if not, I'll explain how that mirroring works someday too. It's way less dummy thicc and way more math geekery.

(if you're $3+, here's the code post)


Related Creators