• Advertisement
Sign in to follow this  
  • entries
    53
  • comments
    225
  • views
    69497

Switching it up

Sign in to follow this  

390 views

As promised, the next toy for my little toy box is a switch.

After all the work I needed to put in for the proximity sensor, this one actually went in quite smoothly. The animation uses the same rigid bind skeletal animation that the doors use. You just create a Maya animation clip on the mesh called "On" (as opposed to the "Open" that doors use) set the object type to "Switch" (which just tells the exporter to try and find a class called "Switch" to create and attach - nice and extensible to support other controller types), and bingo, you have a switch.

I toyed briefly with creating a to-scale wall switch that the player would have to walk up to and press the "Use" button; but in the end, I decided the Head Over Heels approach of just flipping the switch when something bumps in to it opened up a lot more gameplay options, so I went that way. It'd be pretty easy to add an option to the switch to disable the bump-switch behaviour if I ever want the other flavour.

Here's a bunch of grabs showing the character hitting the switch, the switch animation playing, and then the door opening. I waste lots of time (and I mean weeks) texturing things, so to keep me moving, I'm leaving these toys functional for now - and I actually quite like the nice over-sized look of them:

Disabled

I'm still putting off the graphical object editing, so it still requires a quick: "connect switch.state door.open" command to hook it up.

I did briefly have the switch state changing when it was hit, rather than when the "On" animation finished, but delaying the effect of the switch until it finished moving makes the whole thing feel a lot more "solid".

Next, pressure pads.
Sign in to follow this  


6 Comments


Recommended Comments

You could probably abstract the pressure pad into a physics-based switch; past a certain level of force it triggers.

You could then use it for pendulum switches or something.

Share this comment


Link to comment
Thanks for your comments Ravuya - it's nice to know someone reads this stuff! Much appreciated!

By pendulum, you mean kind of like a centrifuge? Spin it fast enough and it switches? That's a cool idea. I do have a nasty secret to admit, my journal lags my coding by a little bit and I actually coded pressure pads up on the train this morning. They're not as cool as your suggestion, but you can tell them how much weight (force) is needed to set them off.

I guess in order to implement pressure pads as a *real* force sensor, I'd need to actually define them as a physics body (as right now, they're just part of the static scenery, which takes up a lot less overhead than a mobile physics body). Might be a nice thing to play around with sometime.

I wonder how "useful" the force metrics you get out of LCP solvers are? I do have an older physics solver plugin I wrote that actually propagated forces explicitly and tried to do a direct solve as events happened. But I suspect reactive solvers (that let an intersection happen, then try and work out what they need to do to correct it) would do a pretty poor job of reporting reliable force information other than for impulses. Have you tried anything like this?

Share this comment


Link to comment
Looks good.

Was wondering how you fixed your opening door animation ? - it looks like you've given the door a frame for it to retract into.

Wyzfen

Share this comment


Link to comment
Alas, I still have no fix for the opening door animation thing. I put that black door frame bit in because for a while, I had a crazy-but-brilliant scheme in mind where I was going to render that black bit into the depth buffer between rendering the door frame and the door itself to mask out any bits of the door that protruded through the frame - but then I realised it would break all the transparency (and any other cool effects that relied on depth, like depth of field). So, the black bit is ugly and temporary ... but they'll be there for a while while I try and add some actual gameplay.

I've basically resigned myself to clip planes - the thinking is that clip planes won't interfere with any other effects I add, and by the time my game ever gets released, it's not going to be taxing the hardware anyway, plus there are only a couple of doors. I'm still hoping I have some flash of insight that gives me a nicer fix - I guess that's part of the reason I'm letting this sit around for a while and playing with other things.

Nice of you to notice =)

Share this comment


Link to comment
Well, I meant centrifuge too, but also clock-style pendulums. You'd start it shaking back and forth by striking it on the side, and it would start rocking. At either of the extreme positions, I guess it would trigger a switch, and shut at the equilibrium position.

I probably need to draw this out.

If you really wanted to get up to the high end of it, you could even build a gear system, and have one of the gears act as a switch to open a door or lift something.

I really like the simplicity of your event linkage, too. You should write some stuff on it. Connecting two variables together seems like an intuitive way to build complex environments without one-off scripts.

Share this comment


Link to comment
I certainly hope to be able to do cool physical-simulation based stuff like that at some point - machines with gears is something that's always appealed to me for some reason too. I've coded up my physics engine to support arbitrary constraints, so it should be possible ... but right now I've got my hands full just trying to get basic character interaction working smoothly with the physics (push, carry, climb, throw, etc). It's certainly a lot more challanging than I thought it would be when I started coding it up.

And in case you're interested, the event linkage piece is actually data-flow. I'm pretty sure there was a honking big gamasutra article on data-flow engines in games a while back. It's a really powerful way to implement generic logic. And unlike pure message based systems (which lose a lot of type information), the introspective nature of data flow gives you lots of things for free - like serialisation, scripting, type conversion, automatic configuration UI generation.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement