Page 1 of 1

moveto and change animation

PostPosted: Mon Oct 15, 2007 4:44 am
by DollMaster
I am trying to make enemies using the move to function. It works fine so far, but I need help. I am clueless as to how to get the enemy to change direction depending on what way he is walking.

So is there an easy way to read movement and place it inside a variable?

Thank you for your help.

Re: moveto and change animation

PostPosted: Tue Oct 16, 2007 3:52 am
by DollMaster
I think my answer lies in the direction and angle function/variables(i do not know what they are). I am clueless as to how to use them.

Would the code go something like this?

angle=direction
if angle==45~315, then direction = right
else if angle==45~135, then direction = up
etc...


Also, people seem to ask the same questions over and over. It would be cool to have a game editor wiki. I want a health bar? I go to the wiki and see all the different types of health bars people submitted.

Re: moveto and change animation

PostPosted: Tue Oct 16, 2007 4:33 am
by DollMaster
I always answer my own questions. Incase any noobzor needs to have their enemies face the direction in which they are walking towards the player, to kill him most likely use this code in the draw actor:

Code: Select all
int dir;

MoveTo("Event Actor", 0.000000, 0.000000, 2.000000, "player1");
dir = direction(x, y, player.x, player.y);

if(dir>=45&&dir<135)
ChangeAnimation("Event Actor", "enemyup", NO_CHANGE);
else if(dir>=135&&dir<225)
ChangeAnimation("Event Actor", "enemyleft", NO_CHANGE);
else if(dir>=225&&dir<315)
ChangeAnimation("Event Actor", "enemydown", NO_CHANGE);
else if(dir<=45&&dir>=0)
ChangeAnimation("Event Actor", "enemyright", NO_CHANGE);
else if(dir>=315&&dir<=360)
ChangeAnimation("Event Actor", "enemyright", NO_CHANGE);

This code works for 4 way movement.

Re: moveto and change animation

PostPosted: Tue Sep 17, 2013 9:16 pm
by SkenderBeu
DollMaster wrote:This code works for 4 way movement.


I think this code works but if a enemy has a collider up in front and your character is hidden behind it, than the enemy has to walk either left or right, but he will be facing upwards.

What we need is the next point in moveTo function so we can change animation accordingly.

Any help on this would be appreciated.

Thanks.