moveto and change animation

Non-platform specific questions.

moveto and change animation

Postby DollMaster » Mon Oct 15, 2007 4:44 am

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.
DollMaster
 
Posts: 65
Joined: Fri Jun 16, 2006 2:38 am
Score: 2 Give a positive score

Re: moveto and change animation

Postby DollMaster » Tue Oct 16, 2007 3:52 am

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.
DollMaster
 
Posts: 65
Joined: Fri Jun 16, 2006 2:38 am
Score: 2 Give a positive score

Re: moveto and change animation

Postby DollMaster » Tue Oct 16, 2007 4:33 am

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.
DollMaster
 
Posts: 65
Joined: Fri Jun 16, 2006 2:38 am
Score: 2 Give a positive score

Re: moveto and change animation

Postby SkenderBeu » Tue Sep 17, 2013 9:16 pm

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.
SkenderBeu
 
Posts: 4
Joined: Tue Aug 13, 2013 7:24 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron