How to make a Star router with construct?

This forum is currently in read-only mode.
From the Asset Store
Casino? money? who knows? but the target is the same!
  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

    You can do that a bit easier with the Distance(x1,y1,x2,y2) expression.

  • > 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.

    >

    You can do that a bit easier with the Distance(x1,y1,x2,y2) expression.

    lol yeah, I guessed there was one of those around Just started using Construct last night, so havn't really got around it much

  • [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.

    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.

    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.

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)