Page 1 of 1

Help with rotational movement animation

PostPosted: Mon Apr 30, 2007 9:15 pm
by kevwalker23
Wonder if anyone can help:- I've got 2 actors, player and enemy. As the (user-controlled) player moves around the screen, the enemy follows and heads towards him, with the enemy having the following DRAW ACTOR action:-

angle=direction(x, y, player.x, player.y);
directional_velocity=2.5;

This works fine movement-wise.

However, the enemy has 36 animation frames (one for every 10 degrees of rotation), the idea being that as the enemy turns and moves towards the player, the animation changes to reflect this. This is the part that I can't seem to get right. I've currently got, under the same DRAW ACTOR action:-

animpos = (angle / 10);

which only seems to work for certain animations (those where the direction is directly left or right of the player)

Anyone know of a better or different way to do this?

Many thanks

PostPosted: Mon Apr 30, 2007 9:42 pm
by jazz_e_bob
Code: Select all
angle = direction(x, y, player.x, player.y);

directional_velocity = 2.5;

animpos = ( angle / 360 ) * nframes;


The first frame of the animation must be facing east.
The animation must then rotate anti-clockwise.

PostPosted: Tue May 01, 2007 5:39 pm
by kevwalker23
Thanks, you're a star!
As someone with very basic programming skills, you've no idea how many hours I've spent trying to puzzle this one out!

Thanks again