Avoiding multiple actors while using MoveTo

Questions, comments and discussion about the Game Editor development.

Avoiding multiple actors while using MoveTo

Postby bamby1983 » Wed Jan 02, 2013 2:20 am

The MoveTo function allows us to specify which single actor we can avoid while moving another actor across the screen. Is there a way by which we can avoid multiple actors using the MoveTo function or any other technique?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby skydereign » Wed Jan 02, 2013 4:14 am

Currently MoveTo can't avoid multiple actors. You can try to get around this by having other actors create the actor to avoid, but it is rather a poor workaround. As for alternate methods, none are too easy. You would have to use some form of path finding, which can be quite hard to implement, or really slow. It helps if you can break things down into a grid, or similar.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby bamby1983 » Wed Jan 02, 2013 5:35 am

Thanks. Is there a way by which I can build a wall or something so that the actor will not be able to pass through that space? That would be an acceptable workaround for my game.

Or would you suggest an activation region that triggers a Move Finish event? Would that actually stop the movement, though?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby skydereign » Wed Jan 02, 2013 8:54 am

Well, if you had thick walls that collided with the actor, that should work. The collision event and PhysicalResponse would prevent the actor from moving through the wall. Only problem is that it will continue trying to move through the wall, and unless its target moves, will never reach it.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby bamby1983 » Sun Jan 06, 2013 3:47 am

I tried this using a swimming pool as a wall (so it was a huge actor) and it didn't do the trick. The actor initially stops but if you continue clicking, he still walks through the pool. I tried using the MoveTo function to make him stop by setting his x and y position values to the present ones but he still walks through if I click enough. Even if I set the collision action to repeat, clicking fast enough allows him to break through and he gets stuck in the middle and it's a struggle to click him out of there again.

As a last ditch effort, I used the following code to simulate a knockback to stop him from walking through with the excess clicking. I still need to write up the direction part of the code. The code below works when the actor approaches from the southwest.

Code: Select all
MoveTo("Soldier_1", Soldier_1.xprevious-5, Soldier_1.yprevious+5, 999, "Game Center", "Pool_Water");


It's still annoying as the character keeps freezing as he walks along the border.

I also tried another approach where I saved the xmouse and ymouse values in another pair of variables upon mousedown, then set the collision to move him back 5 steps using formula that involved x and xprevious and then used the MoveFinish event to direct him to the original co-ordinates by reloading the stored mouse position values. Same issue, although he is redirected to the new location in this case.

Do you know anything else that may work? If not, I guess I'll have to just make him swim instead of finding his way around the pool.
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby skydereign » Sun Jan 06, 2013 4:03 am

bamby1983 wrote: Even if I set the collision action to repeat,

Just so you know, this is usually what you have to do when handling collisions.

bamby1983 wrote:It's still annoying as the character keeps freezing as he walks along the border.

Well, that's what I meant by continues trying to move through the wall. There isn't a good built in workaround to this. I have setup my own MoveTo mechanism before, creating a graph that the actors can move through. Essentially you create paths that the actor can move through, and pick their destination by which point is closest. That way you can ensure (assuming the obstacles aren't moving) that the actor will move through an unblocked spot.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby bamby1983 » Sun Jan 06, 2013 4:32 am

skydereign wrote:
bamby1983 wrote: Even if I set the collision action to repeat,

Essentially you create paths that the actor can move through, and pick their destination by which point is closest. That way you can ensure (assuming the obstacles aren't moving) that the actor will move through an unblocked spot.


Is there any way in which the actor can be constrained to defined paths in one part of the map but move freely in other parts?

Also, do paths need to be one-dimensional or can I draw branches from them? Say I have a room and I want my unit to be able to move freely in it in all directions. How would that be achieved with paths? Can I draw multiple crisscrossing paths and somehow make the actor jump from one to the other?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby skydereign » Sun Jan 06, 2013 4:48 am

bamby1983 wrote:Is there any way in which the actor can be constrained to defined paths in one part of the map but move freely in other parts?

It is. You can have the actor stop following the path at any time. All you would need to do is have a variable set when it needs to follow a path.

bamby1983 wrote:Also, do paths need to be one-dimensional or can I draw branches from them? Say I have a room and I want my unit to be able to move freely in it in all directions. How would that be achieved with paths? Can I draw multiple crisscrossing paths and somehow make the actor jump from one to the other?

Here's the idea. You have a bunch of nodes that can be connected. A node can be connected to no other nodes or all of the other nodes. An actor being moved by this would only move between nodes that are connected. Bare in mind that these aren't gE's built in paths, but something you have to implement. Using the graph created by the nodes and the connecting edges between them, you can write a relatively simple shortest path system for the actor to move through.

So yes, you can draw crossing paths. Not sure what you mean by jump paths, but you can move the actor to a completely new spot, and have it start following its location.
Image
The path structure would look something like this. The actor would be associated with a certain position, and the place it is trying to move to would be another. It can follow the lines to get to the destination. Or, you could have it stop following the grid at any time.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby bamby1983 » Sun Jan 06, 2013 9:15 pm

Thanks for the detailed response and the example graph. I have created a path and wanted to have the actor jump onto it when he enters an activation region. However, I cannot find any tutorials on activation regions on the forums. Would you know how to use these? I don't see a region name or ID anywhere, so how would I identify a region?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby skydereign » Sun Jan 06, 2013 9:54 pm

How did you create the path? gE paths are different from the type of path I'm talking about, so if you were trying to set that up, you'll have to do something else entirely. Activation regions on the other hand don't work like you are thinking. They don't activate actors they come into contact with. The main idea is that the regions themselves are active if the view is within them. Any actor within an active activation region exist, and run properly. When the view leaves the region, everything within the region disappears/disables.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby bamby1983 » Mon Jan 07, 2013 1:02 am

I used the standard GE paths.Which paths did you have in mind and how would I implement them? Are you referring to something on the lines of a list of waypoints so the actor can only move form one waypoint to the other?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Avoiding multiple actors while using MoveTo

Postby skydereign » Mon Jan 07, 2013 1:23 am

bamby1983 wrote:I used the standard GE paths.Which paths did you have in mind and how would I implement them?

I did not meant gE paths.
skydereign wrote:Bare in mind that these aren't gE's built in paths...


bamby1983 wrote: Are you referring to something on the lines of a list of waypoints so the actor can only move form one waypoint to the other?

Yes and no. They don't strictly have to follow the paths (the actual line between points), but they use it to determine the locations to move to, while trying to get to a final location. To set this up it takes a bit of coding knowledge. The easiest method to set this up involves a 2d square array, and use actors to symbolize the actual nodes. You can make the game connect the actors together via the 2d array for you, by connecting the ones close to each other (using cloneindex to determine which the nodes). You'd also need to create the actual shortest path function to determine which node to move to next. So it is a bit of work to setup, but it does bypass the problem you are currently facing and it is one of the easier solutions.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron