Ok, so I am making a zombie apocalypse game. However, I'm having some trouble trying to get the zombie to chase people. I want the zombie to chase any of the people that get near it, but I don't won't to make a ?
distance to [person v]for every single person I make. Is there any way I can make 1 ?
distance to [person v]work for all of the people?
Offline
Nope. D: Sometimes you just have to tough it out.
Offline
I can't think of anyhing
Offline
Not really. You could put all of the distances in a list with a loop and look for the lowest number
Offline
Well you could name the people "1", "2", "3", etc. Then you use the script:
when gf clicked set [chase v] to (0) forever set [min-dist v] to (1000) set [sprite v] to (0) change [sprite v] by (1) if <(distance to (sprite)) < (min-dist)> set [min-dist v] to (distance to (sprite)) set [chase v] to (sprite) end change [sprite v] by (1) if <(distance to (sprite)) < (min-dist)> set [min-dist v] to (distance to (sprite)) set [chase v] to (sprite) end change [sprite v] by (1) if <(distance to (sprite)) < (min-dist)> set [min-dist v] to (distance to (sprite)) set [chase v] to (sprite) end change [sprite v] by (1) if <(distance to (sprite)) < (min-dist)> set [min-dist v] to (distance to (sprite)) set [chase v] to (sprite) end change [sprite v] by (1) if <(distance to (sprite)) < (min-dist)> set [min-dist v] to (distance to (sprite)) set [chase v] to (sprite) end if <(chase) > (0)> point towards (chase) move (5) steps end endAnd this way, you only have to copy and paste the middle thing as many times as you need to, instead of doing each individual.
Last edited by AtomicBawm3 (2012-03-01 19:48:34)
Offline