Page 1 of 1

Following obiect avoiding other object

PostPosted: Sat May 16, 2009 11:59 am
by naoh
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?

Re: Following obiect avoiding other object

PostPosted: Sat May 16, 2009 12:40 pm
by skydereign
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.

Re: Following obiect avoiding other object

PostPosted: Sat May 16, 2009 4:37 pm
by Hblade
Why not jsut use "Move to" actor2 and avoid wall that way o.o.

Re: Following obiect avoiding other object

PostPosted: Sat May 16, 2009 6:46 pm
by naoh
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!