This site requires JavaScript, please enable it in your browser!
Greenfoot back
grantmarcum
grantmarcum wrote ...

2014/4/15

Creating a simple turret that shoots an enemy when it is in range

grantmarcum grantmarcum

2014/4/15

#
we are creating a game like league of legends, where an automatic turret will shoot an enemy and an enemy minion when it comes in range, the turret doesnt need to shoot your hero and your minions, just the enemy, i need help creating this automatic turret that automatically shoots the enemy hero, and the enemy minion, i would appreciate if anyone can help me.(the turret doesnt need to rotate)
danpost danpost

2014/4/15

#
When the turret is ready to shoot or is reloaded (shot delay timer has expired), you probably want the turret act method to use 'getObjectsInRange' to get all possible targets; iterate through the list for the closest instance of an enemy hero or minion; and, if one exists in range, produce a shot that is directed toward its location.
grantmarcum grantmarcum

2014/4/15

#
we tried the getobjectsintange method, but we dont know where to start on the code for the turret, ive looked everywhere and all ive seen is turrets controlled by the user, using the iskeydown method
danpost danpost

2014/4/15

#
First, create the bullet or shot class (whatever you want to call the projectile that the turret will be shooting out). Then, create a simple 'fire' method in the class of the turret to create a projectile. Then implement a timer to regulate the launching of the projectiles. After that, you can ask about finding targets in range to fire at.
You need to login to post a reply.