How to make a Star router with construct?

For questions about using Classic.

Post » Fri Jan 07, 2011 1:35 am

How do you make a AI Star Router?

For example, how you make a AI that for example get a choice to go to X point, it have choice of

go to location 1, 2 or 3.

How you program that it can make choices? and how to calculate what way to walk?

And how works a Lee router, how you make that with construct?

My experience with construct is that its the most powerfull 2D game engine there is but I dont have found yet a example how to do this kinda things and i'm positive that it is posible with construct, buth i'm not a programmer.
B
43
S
8
G
5
Posts: 110
Reputation: 3,605

Post » Fri Jan 07, 2011 4:09 am

Are you choosing a random point (out of a few points) for the AI to go to? If so, look into using 'random()' which generates a random number for a variable. Then compare for each variable and if the variable equals this or that then tell the AI to go to a certain point. Something about it should be on the Construct wiki.

It also sounds like you're doing top-down view so you might try RTS Behavior to make the AI walk to where you want it to go. It is very useful.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Fri Jan 07, 2011 10:48 am

You can go with the random() option, but the most common ( at least that I've seen in games ), is doing like most humans do, target the closest one.
To do this you could use pythagoras ( a^2 * b^2 = c^2 ), where a = object.X - target.X and b = object.Y - target.Y, do this to find the distance between all the targets ( on screen or whatever ) and check for which distance is the shortest. If some distances are equal, just take the first one or run the test again, considering the chances that something has moved.

There might be a better way, but this idea popped into my head. Can't really consider it much though, as I am in class.
B
1
G
1
Posts: 2
Reputation: 429

Post » Fri Jan 07, 2011 2:06 pm

[quote="Smilex":1c9v9exi]You can go with the random() option, but the most common ( at least that I've seen in games ), is doing like most humans do, target the closest one.
To do this you could use pythagoras ( a^2 * b^2 = c^2 ), where a = object.X - target.X and b = object.Y - target.Y, do this to find the distance between all the targets ( on screen or whatever ) and check for which distance is the shortest. If some distances are equal, just take the first one or run the test again, considering the chances that something has moved.

There might be a better way, but this idea popped into my head. Can't really consider it much though, as I am in class.[/quote:1c9v9exi]

You can do that a bit easier with the Distance(x1,y1,x2,y2) expression. :mrgreen:
B
7
S
2
G
4
Posts: 164
Reputation: 2,418

Post » Fri Jan 07, 2011 2:36 pm

[quote="Citnarf":2mxw9qb2][quote="Smilex":2mxw9qb2]You can go with the random() option, but the most common ( at least that I've seen in games ), is doing like most humans do, target the closest one.
To do this you could use pythagoras ( a^2 * b^2 = c^2 ), where a = object.X - target.X and b = object.Y - target.Y, do this to find the distance between all the targets ( on screen or whatever ) and check for which distance is the shortest. If some distances are equal, just take the first one or run the test again, considering the chances that something has moved.

There might be a better way, but this idea popped into my head. Can't really consider it much though, as I am in class.[/quote:2mxw9qb2]

You can do that a bit easier with the Distance(x1,y1,x2,y2) expression. :mrgreen:[/quote:2mxw9qb2]

lol yeah, I guessed there was one of those around :P Just started using Construct last night, so havn't really got around it much
B
1
G
1
Posts: 2
Reputation: 429

Post » Fri Jan 07, 2011 7:15 pm

[quote:172ooo27]Are you choosing a random point (out of a few points) for the AI to go to? If so, look into using 'random()' which generates a random number for a variable. Then compare for each variable and if the variable equals this or that then tell the AI to go to a certain point. Something about it should be on the Construct wiki. [/quote:172ooo27]
I'm choosing most importent point.

[quote:172ooo27]It also sounds like you're doing top-down view so you might try RTS Behavior to make the AI walk to where you want it to go. It is very useful.[/quote:172ooo27]
This is very helpful, did not know that you can use RTS behavior for this, have to experiment with this still.

[quote:172ooo27]You can go with the random() option, but the most common ( at least that I've seen in games ), is doing like most humans do, target the closest one.
To do this you could use pythagoras ( a^2 * b^2 = c^2 ), where a = object.X - target.X and b = object.Y - target.Y, do this to find the distance between all the targets ( on screen or whatever ) and check for which distance is the shortest. If some distances are equal, just take the first one or run the test again, considering the chances that something has moved.

You can do that a bit easier with the Distance(x1,y1,x2,y2) expression. [/quote:172ooo27]
Don't know if that works in my case because its in a dungeon, I need to calculate the shortest route it really has to travel.
B
43
S
8
G
5
Posts: 110
Reputation: 3,605


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests