Skip to content

Commit

Permalink
find_actor_by_label is only available in editor. Changed to loop
Browse files Browse the repository at this point in the history
  • Loading branch information
rstager committed Jun 20, 2017
1 parent 392ed28 commit 94f2a2a
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions Content/Scripts/AIAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@

class SplinePath:
def __init__(self,actor,label):
landscape=actor.get_world().find_actor_by_label(label)
self.component=actor.get_actor_component_by_type(SplineComponent)
if (self.component==None):
self.component = actor.add_actor_component(SplineComponent, 'Spline to follow')
self.component.SetClosedLoop(True)
self.component.ClearSplinePoints()
for segment in landscape.SplineComponent.Segments:
first = True
for p in segment.Points:
if not first:
self.component.AddSplineWorldPoint(p.Center)
else:
first = False
self.max_distance = self.component.get_spline_length()
self.distance = 0.0
for landscape in actor.all_actors():
if(landscape.get_name() == label):
self.component=actor.get_actor_component_by_type(SplineComponent)
if (self.component==None):
self.component = actor.add_actor_component(SplineComponent, 'Spline to follow')
self.component.SetClosedLoop(True)
self.component.ClearSplinePoints()
for segment in landscape.SplineComponent.Segments:
first = True
for p in segment.Points:
if not first:
self.component.AddSplineWorldPoint(p.Center)
else:
first = False
self.max_distance = self.component.get_spline_length()
self.distance = 0.0
return
print("Didn't find landscape ",label)

def loc_at(self,distance):
return self.component.get_world_location_at_distance_along_spline(distance % self.max_distance)
Expand Down

0 comments on commit 94f2a2a

Please sign in to comment.