I'm making game and I would like the enemies to shoot objects at the player if the player is within a certain range. Does anyone have any code that would do that, so far the code I've come up with doesn't work consistently?
Offline
when gf clicked forever if <(x of player) = [10]> broadcast [shoot] end end
Last edited by GameCentral (2012-03-09 19:28:55)
Offline
Use these scripts.
In the enemies:
when gf clicked forever if <(distance to [player v]) < (50)> //or another distance broadcast [shoot v] end add movement scripts hereIn the missiles:
when gf clicked hide when I receive [shoot v] go to [enemy v] show glide (0.5) secs to x:([x position v] of [player v]) y:([y position v] of [player v]) //adjust for a faster/slower speed hideIn the player:
when gf clicked forever if <touching [missile v]?> change [health v] by (-1) //or another value end more scripts hereThese scripts are very simple and rather inefficient but they should work.
Last edited by trinary (2012-03-10 00:18:45)
Offline
trinary wrote:
Use these scripts.
In the enemies:when gf clicked forever if <(distance to [player v]) < (50)> //or another distance broadcast [shoot v] end add movement scripts hereIn the missiles:when gf clicked hide when I receive [shoot v] go to [enemy v] show glide (0.5) secs to x:([x position v] of [player v]) y:([y position v] of [player v]) //adjust for a faster/slower speed hideIn the player:when gf clicked forever if <touching [missile v]?> change [health v] by (-1) //or another value end more scripts hereThese scripts are very simple and rather inefficient but they should work.
that works better
Offline