Help with rotational movement animation

Game Editor comments and discussion.

Help with rotational movement animation

Postby kevwalker23 » Mon Apr 30, 2007 9:15 pm

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
kevwalker23
 
Posts: 5
Joined: Fri Sep 03, 2004 8:21 pm
Score: 0 Give a positive score

Postby jazz_e_bob » Mon Apr 30, 2007 9:42 pm

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.
Attachments
animation angle demo.zip
(9.86 KiB) Downloaded 111 times
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby kevwalker23 » Tue May 01, 2007 5:39 pm

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
kevwalker23
 
Posts: 5
Joined: Fri Sep 03, 2004 8:21 pm
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron