Following obiect avoiding other object

Game Editor comments and discussion.

Following obiect avoiding other object

Postby naoh » Sat May 16, 2009 11:59 am

I'm using code in actor1
Code: Select all
angle = direction(x, y, actor2.x, actor2.y);
directional_velocity = 3;

And collision event for object wall of actor actor1

But it's looks like that:
Image

And I want situation like this:
Image

How I can do that?
naoh
 
Posts: 10
Joined: Wed Jan 28, 2009 4:01 pm
Score: 2 Give a positive score

Re: Following obiect avoiding other object

Postby skydereign » Sat May 16, 2009 12:40 pm

Hm... this would be pretty tricky if you want to do it that way. To make this easier, you should use the moveto function, that way it can avoid the object you want. Is there a reason you are using angles? Because if it is just for movement, not tied to animation, then all you would need to use is the moveto function. If you want to implement angles for the animation, then you would either need a shortest path, I don't suggest trying to make one, or create a way of determining rotation from xy speeds. I am assuming that this is just a basic idea of what you want, and that the circumstance will change, so you want it to still work.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Following obiect avoiding other object

Postby Hblade » Sat May 16, 2009 4:37 pm

Why not jsut use "Move to" actor2 and avoid wall that way o.o.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Following obiect avoiding other object

Postby naoh » Sat May 16, 2009 6:46 pm

Those are my first days with the Game Editor, so I don't know many functions. Before I work with the Game Maker and it's so hard to me to get used to the GE.
I think function moveto work fine, but why it don't work when I use region as actor to avoid?

EDIT:
Strange, but sometimes it work, sometimes no.
My code in actor1 is:
Code: Select all
MoveTo("Event Actor", player.x, player.y, 2, "Game Center", "wall");


On start it works, but when player will move above wall object, and then will back under wall, actor1 will walk through wall!
naoh
 
Posts: 10
Joined: Wed Jan 28, 2009 4:01 pm
Score: 2 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron