Animated Rotation for character (Tech Demo-ish thing)

Started by Ali, Sun 01/04/2007 12:53:50

Previous topic - Next topic

Ali

I wanted to see if I could make a character animate when turning on the spot. I noticed that larger pre-rendered 3D characters looked a little jerky when rotating through 8 directions. I've cobbled together a little script that allows them to animate while rotating - so they could rotate smoothly or step round in a circle realistically.

You can download the game files here (4.09mb):

http://themonkeyhut.tripod.com/Animated_Rotation.html

I will probably replace the on-mouse-click script with a animated turning function that could be called from any script.

The script doesn't work perfectly at the moment. It seems to me that the regular walking function doesn't use diagonal loops, so when he walks diagonally the character snaps into either north, south east or west.

I was wondering if you guys could help me work out a way of specifying what loop to play while the character is walking, so this would work more smoothly. I also wanted suggestions on how to streamline and improve my scripting, because I know nothing about this sort of thing.

I'd apprecate any feedback, including whether this would be at all useful to anyone.

joelphilippage

Great Job! I tried it out and it works great. Ill probably use this for my next game.



Ashen

Quote
It seems to me that the regular walking function doesn't use diagonal loops, so when he walks diagonally the character snaps into either north, south east or west.

For some reason, diagonal loops have to have at least 2 frames (the 'stationary' one, and one other) to be used in waking. For testing purposes, adding the first frame again works fine - characters should then be able to walk diagonally. Does that take care of the "I was wondering if you guys could help me work out a way of specifying what loop to play while the character is walking," part, or is there another reason for that?
I know what you're thinking ... Don't think that.

Kweepa

#3
Heh, Ashen beat me to that.

There are a couple of problems:

1. You rotate towards the click point (quantized to 45 degree angles), then start walking. What you should really be doing is rotating towards the first path point (quantized) which you can find from GetMovementPathWaypointCount, GetMovementPathWaypointPosition. You might have to have a dummy character to represent the main character so you can steal data from it after it's started moving.

2. While the character is walking, you could force his position to an interpolated position along the movement path from the dummy character, and at each waypoint decide which turn animation to play based on the angles of the path segments coming into and going out of the waypoint. But unless you were happy with the character stopping first, you'd get problems with the foot positions not lining up to the start of the turn animation.

As for streamlining your scripting, you should first move this into a module. It sounds complicated but it's really pretty simple. All you should need to do to begin with is have an on_mouse_click and a repeatedly_execute_always function in your module.

Secondly, you're using a lot of global variables that aren't needed outside the on_mouse_click function, or in the next mouse click, so they can be safely made local. Just define and use them inside on_mouse_click.

You have a lot of almost-repeated code. It's a shame AGS isn't good at look-up tables because this would be perfect for it.
Still waiting for Purity of the Surf II

Ali

Thanks guys, I didn't know diagonal loops needed more than one frame.

Thanks for the food for thought Steve. Point one makes a lot of sense sense. I've not looked into Movement Waypoints, but I think that sounds straight forward.

As for point two, that sounds very tricky. I'll have to have a careful think about that. I wonder if the character stopping would be too irritating on a complicated path.

Thanks again,

- Al

SMF spam blocked by CleanTalk