Skip to content

Commit

Permalink
turrets now only fire when within range
Browse files Browse the repository at this point in the history
  • Loading branch information
gandalf3 committed Dec 25, 2015
1 parent d0c91fd commit 4405f7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Binary file modified lonely_photon.blend
Binary file not shown.
18 changes: 12 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, own):
self.target = logic.getCurrentScene().objects[playername]

self.fireRate = .1
self.range = 8
self.range = 20

if not self.get("projectile", 0):
self.projectile_type = "standard_projectile"
Expand All @@ -49,13 +49,19 @@ def __init__(self, own):

def aim(self):

hit = self.rayCast(self.target, self, 0.0, "solid", 0, 1, 0)
if hit[0] == self.target:
self["cansee"] = True
self.alignAxisToVect(hit[2], 0, 1)
distance = utils.velocity2speed(self.target.worldPosition - self.worldPosition)

if distance < self.range:
hit = self.rayCast(self.target, self, 0.0, "solid", 0, 1, 0)

if hit[0] == self.target:
self["cansee"] = True
self.alignAxisToVect(hit[2], 0, 1)
else:
self["cansee"] = False
else:
self["cansee"] = False

return self["cansee"]


Expand Down

0 comments on commit 4405f7d

Please sign in to comment.