diff --git a/lonely_photon.blend b/lonely_photon.blend index 8ef1325..92e04df 100644 Binary files a/lonely_photon.blend and b/lonely_photon.blend differ diff --git a/main.py b/main.py index d2417e3..da3b28d 100644 --- a/main.py +++ b/main.py @@ -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" @@ -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"]