Actor Wanting to Choose Random Path

Game Editor comments and discussion.

Actor Wanting to Choose Random Path

Postby GregSmith » Sat Dec 03, 2005 11:18 pm

If an actor is already moving along a predefined path, with animation, and he comes to a region where he could progress by switching to any one of a number of predefined paths that appear to merge at that juncture, what would be the simplest, non-coding solution to cause that actor, with his animation, to continue moving along any of those other paths, in a random order?

To clarify the problem:

Imagine a psuedo-3D scene where the actor is moving "away" from the camera into the distance, getting smaller, to simulate perspective. He then comes to a rock formation and could move on a predefined path to the left, the right, "around" the rock formation, or back toward the camera. Depending on which path was taken, his animation would change to reflect which direction he was traveling toward.

So, two things would happen at the same moment: the actor would randomly switch paths, and, depending on which path was selected, would also change his animation to correspond with that path direction.

Thanks,

Greg Smith
GregSmith
 
Posts: 9
Joined: Mon Jul 11, 2005 12:16 am
Score: 0 Give a positive score

Postby Novice » Sun Dec 04, 2005 10:18 am

You can do it this way:
on path finish --> change path (random)
but then you will have the problem you will have to have only 4 paths because if you have more they will all be included in the random path chnage.

The better way to do it includes little coding so bear with me.
Here we are assuming that your animation and path names are 1,2,3,4.
path finish(1)--> script editor
Code: Select all
int animation=rand(2);

if (animation==0)
{
    ChangePath("Event Actor", "2", BOTH_AXIS);
    ChangeAnimation("Event Actor", "2", FORWARD);
}
else if (animation==1)
{
    ChangePath("Event Actor", "3", BOTH_AXIS);
    ChangeAnimation("Event Actor", "3", FORWARD);
}
else if (animation==2)
{
    ChangePath("Event Actor", "4", BOTH_AXIS);
    ChangeAnimation("Event Actor", "4", FORWARD);
}


Just paste this in to script editor i checked it and it works.
Hope it helps.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby GregSmith » Mon Dec 05, 2005 5:08 pm

Novice:

Thanks for the advise. I would prefer to refrain from coding whenever possible, so the 4 path limitation might be o.k. Can a path be constrained to rotate and advance along another path? That would allow for some very "random-like" behavior, especially if the sprite were animated independtly of its path movements.

Greg Smith
GregSmith
 
Posts: 9
Joined: Mon Jul 11, 2005 12:16 am
Score: 0 Give a positive score

Postby makslane » Mon Dec 05, 2005 5:18 pm

You can use parented actors to make composite paths.

For example:

- Put the path1 in the actor1
- Put the path2 in the actor2

Now, make the actor1 parent of actor2

The actor1 will move along the path1, and the actor2 will move along the path2, but the final movement for the actor2 will be the composition from path2 with path1.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest