Problem with Constrain to Plane...

Hi there, I’m creating a top-down shooter that requires players to always be at the exact same Z level, which means I need to constrain them to a normal, I’ve got that since it’s very easy to set up. My only problem is the character spawns slightly above the floor, and is in a falling state. I’m trying to figure out the best possible way of doing this without giving the map creator overhead, ideally I’d just like things to work for them. I want the character to walk/run on spawn, not fall/fly.

I’m thinking either somehow spawning them on the floor itself, somehow, I don’t know how to do this (and I don’t mean slightly above and falling a couple inches at first). Another way might be to snap to a set plane using Snap to Plane at Start, and then tricking the game somehow to think you’re in a walking state, so yes that would mean walking in the air, I’d be fine with that.

Anyone have any ideas how I can accomplish either of these, or maybe even a better idea. What I’m trying to accomplish is perfect (or closest to) 2D, top-down movement, the character should never go up or down even when an explosion or something is near them. Thanks!

Why not spawn the characters on a plane off screen like during a ‘loading screen’ and then move them via script to the starting location? Not exactly the most efficient way but I promise you won’t have that couple inch fall in the release, ha.

There are a few different ways that come to mind in handling this though. As you said, if the characters are all going to be on the Z-plane at a specific location then just remove the falling animation and exclude the ability to go up and down. Though I wonder how you plan on handling stairs if you lock the characters to a specific Z location?

The problem with restricting characters to a specific Z-axis in a psuedo-2d world is you’re dealing with more then just bitmaps so the easiest solution I can offer is what I suggested above. Or simply before they spawn do a raycast to the floor and move the character to the lowest spot traced.

Also, if you don’t want characters to go up or down then you’re wanting to remove character physics from your well… character. Or just don’t have them respond to physics related stuff. :), hope this helped.

I’ve got it working, sort of, I’m not really sure why this works but if I set PlaneConstraintNormal to 0,0,1 and Constrain to Plane = true (locks to X and Y movement only) and DefaultLandMovementMode = Walking it spawns me in the walking state, and I am walking on the floor/ground. Now I have another problem, if I go off a ledge it switches to the flying state which is awesome! it gave me a whole new idea for my game, I want this! However, if I go back onto “land” it doesn’t switch back to the walking state, even though the Z hasn’t changed at all. Maybe I’ll have to set up some debugging text to show the Z value just to make sure it isn’t changing. However, any ideas as to why it wont switch back to walking?

Thanks for the reply btw!

No problem, happy to help.

Also i’m glad that you found a new avenue in your adventures. It’s part of the excitement, :). I’m almost positive that if you make your debugging text to keep track of the Z-coordinate you’ll find your answer as to why the character isn’t walking. If not then post back with the results and if it did work please let us know that too!

I’m now logging the Z value and it isn’t moving at all. I tried loading up multiple clients and I watched the other client move around. It actually picks up the walking animation and flying animation as expected, just not on the local client (and it’s not just the animation, it affects movement as well). I’ve got to go for now but I’ll try and report any progress tonight. Thanks again.

I figured maybe it was the height of the capsul that was changing when in falling state but that isn’t it. Does anyone have a proper solution for a top down, locked on Z plane that allows your character to walk and not float in the air??

I really, REALLY don’t like doing the work for other people but here you go.

When walking or however you decide to move you need to do the following:

Then just set a control statement or an iteration to keep them locked down. You’ll want to determine your own Z height though in what works for you. There are other ways of going about it but this will work for what you want. Hope this helps. :slight_smile:


Get and Set methods are your friends!

Also updating the code as of 6/13/2014 for v4.2 update!