Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to change weight_scale on runtime #6531

Closed
MarianoGnu opened this issue Sep 18, 2016 · 6 comments
Closed

Add a way to change weight_scale on runtime #6531

MarianoGnu opened this issue Sep 18, 2016 · 6 comments

Comments

@MarianoGnu
Copy link
Contributor

Today i've been using the AStar pathfinding class, and it works really well, but i found myself with a problem, i wanted change the scale of some points to prevent the player from moving over there, but there's no way to change it. Other way to do it was removing all the conections and add them back again, but chaging the weight scale is easier imo, besides, my game will most likely need to have different weight scales for every character (sinces some of them walks, other rides a horse and others flyes) and terrain weigth is linked to this.
So there are 2 things i'd like to be able to do:

  1. have a set_weight_scale(int point_id) function
  2. have a set_custom_weigth_calculator(object, string function_name)
    func function_name(int point_from, int_point_to)
@akien-mga akien-mga changed the title [Feature Request] Add a way to change weight_scale on runtime Add a way to change weight_scale on runtime Sep 18, 2016
@reduz
Copy link
Member

reduz commented Sep 18, 2016

I am still unconvinced about how it works with weight.

  1. Should weight be a multiplier or an extra distance?
  2. Should weight be by node or connection?

On Sun, Sep 18, 2016 at 12:29 AM, Mariano Javier Suligoy <
[email protected]> wrote:

Today i've been using the AStar pathfinding class, and it works really
well, but i found myself with a problem, i wanted change the scale of some
points to prevent the player from moving over there, but there's no way to
change it. Other way to do it was removing all the conections and add them
back again, but chaging the weight scale is easier imo, besides, my game
will most likely need to have different weight scales for every character
(sinces some of them walks, other rides a horse and others flyes) and
terrain weigth is linked to this.
So there are 2 things i'd like to be able to do:

  1. have a set_weight_scale(int point_id) function
  2. have a set_custom_weigth_calculator(object, string function_name)
    func function_name(int point_from, int_point_to)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#6531, or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z23ff_teNf9eNfKIUvuEZg0EestGTks5qrLAygaJpZM4J_ybW
.

@MarianoGnu
Copy link
Contributor Author

Well, in some cases you don't want weight to be related to distance, this was the case in the first time i used AStar, in a tabletop board game, i was doing the movement of the pieces around the table, and there was no weight on the nodes at all, except when there was another player in the middle.
that's why i recomended delegating the weight to a custom function, passing the id of the nodes from and to you are moving, you can access to the position, distance and weight scale using the functions already available on the AStar API, if you just want to make linear movements you could just use the formula it's already builtin.

@reduz
Copy link
Member

reduz commented Sep 26, 2016

probably doing what Mariano suggests (a callback to get weight) might work
too?

On Mon, Sep 26, 2016 at 5:09 PM, Clint Fleetwood [email protected]
wrote:

Another need to have weights at runtime is lets say that unit A can go
over water at 3x speed and unit B can go over water at 0.5x speed. Well
when it is unit A's turn the weights need to be different than when it it
is Unit Bs turn. I'd say keep it a multiplier.
Now by Node or Connection.. I really don't have an opinion.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#6531 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z2515ep0Olldc-_PRnT7VNVrrZJukks5quCaMgaJpZM4J_ybW
.

@cefleet
Copy link

cefleet commented Sep 26, 2016

I wrote a long comment basically repeating when Mariano said and realized I just repeated him. Currently I add and remove connections before each units turn. But yeah.. what he said.

@MarianoGnu
Copy link
Contributor Author

another point on calculatin weights, right now weights are per node, now imagine a node in the top of the cliff, you probably want your AI to jump down the cliff (in other words, a one way collision) but not the oposite way, because he can't jump higth enought to reach the other side, this means it needs a one way connection, a way to solve it is using the function i described and use a raycast to check if it's possible to move from one point to the other. also imagine a map with a mountain, it's posible to move up and down the mountain, but maybe you want to have a bigger weigth if you are climbing up.

@bojidar-bg
Copy link
Contributor

Closing as fixed by #8146, feel free to comment/reopen if this is not the case.

@akien-mga akien-mga added this to the 3.0 milestone Jun 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants