Top-down movement with legs/torso separate

For questions about using Classic.

Post » Sun Aug 01, 2010 7:59 pm

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
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Tue Aug 03, 2010 3:08 am

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...
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Tue Aug 03, 2010 4:24 am

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)
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Tue Aug 03, 2010 1:33 pm

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
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Tue Aug 03, 2010 3:44 pm

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 :P
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Tue Aug 03, 2010 5:49 pm

Actually the new vector object might be good for this.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Aug 06, 2010 4:53 pm

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.

[url:1avl7o2x]http://www.mediafire.com/?dv67suhj1bp145p[/url:1avl7o2x]

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 :)
B
15
S
6
G
6
Posts: 103
Reputation: 2,968


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests