Top-down movement with legs/torso separate

This forum is currently in read-only mode.
From the Asset Store
Set of tiles to create a map for top-down games with island theme
  • Hi all,

    I've been pondering creating a top down view adventure type thing, and thought it might look smoother using the technique of having the legs and torso as separate objects, allowing the mouse to be used to free-view while the legs can move in WASD directions or whatever. Seen it used in a few flash games and it looks nicer than having a bunch of clunky animations which would only be more time-consuming.

    Anyways, the legs would obviously have to follow a few rules (rotating along with the torso when they hit a certain point for example).

    I've had a search around but can't find anything on the subject - does anyone know a good way to implement this? It may have even been done before but I couldn't find anything when I did a search, so any ideas would be great

    Cheers

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just going back to this... is there an efficient method of rotating a sprite (not just setting a direct angle, but actually making a quick spin) to one of four or more set angles?

    So for example if your sprite (from above) was facing left and you press the down arrow he'll quickly turn 90 deg anticlockwise, then pressing the up arrow would make him spin 180 deg anticlockwise so that he was facing upwards, etc...

  • Depending on your trigger you could just use lerp the top objects angle to the bottom objects angle.

    You would have to make sure than the angles never get too far apart tho... wouldn't want it doing a scene from the exorcist.

    ->on trigger

    top set angle to lerp(.angle, bottom.angle, something* timedelta)

  • Cheers newt, that's the kindof thing I was thinking, only problems with this method are that it doesnt work for diagonals (so if you hold W and D you don't always face northeast) and it appears to sometimes rotate 270 one way when it could go 90 the other! Haha

  • All I really need is a variation of the 8 directional movement behaviour, except I also need it to rotate 180 degrees rather than just flip... so much maths

  • Actually the new vector object might be good for this.

  • I managed to get the 'legs' functioning nicely, it sortof works like an enhanced version of smooth 8 way movement now.

    The next challenge is going to be interesting... what I want is to have the torso always look at the mouse pointer. That part is simple, I've already put it in. The more complicated bit is to orientate the legs after a certain rotation.

    If you think about your body, you can turn your upper body about 90 degrees before you have to move your feet and change orientation completely. This is what I'm trying to emulate - the upper body will hit a certain angle then the legs will move to compensate.

    The way I have my legs set up is using a single sprite with one angle (default 0, right). I borrowed Intrepids's cap on rotation to test this out and have edited it to a point where it uses a new system. A second object is used to set the outright orientation while the legs smoothly work round a circle to match the angle. WASD keys are assigned a number - meaning that they can be added/subtracted to give unique numbers for each direction. This allows diagonal movement aswell. So when you press W for example, the second object looks directly at the vector 0, -1 (vertically up) and the legs will then smoothly rotate to face upwards from whichever direction they were previously facing. This is done by having events for each number (which is stored in a private variable in the leg sprite) which tell it what action should happen.

    It's still in a simple stage but here's a cap so it might be easier to understand. I think I'm still running .91 and not the latest unstable, so it should be ok for most.

    http://www.mediafire.com/?dv67suhj1bp145p

    If anyone can suggest ways to make this more efficient (it looks rather messy to me) or any theories on implementation I'd love to hear them

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)