Skip to content

Commit 08da606

Browse files
author
Roberto De Ioris
authored
Create Splines_API.md
1 parent ca5f18f commit 08da606

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/Splines_API.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# The Splines API
2+
3+
Splines are another amazing UE4 feature.
4+
5+
The following component shows how to move another actor over a spline path:
6+
7+
```py
8+
class Spline:
9+
def begin_play(self):
10+
# get a reference to a spline component
11+
self.spline = self.uobject.get_owner().get_actor_component_by_type(ue.find_class('SplineComponent'))
12+
# find the length of the spline
13+
self.max_distance = self.spline.get_spline_length()
14+
self.distance = 0.0
15+
# get a reference to the actor to move (as a blueprint property)
16+
self.actor_to_move = self.uobject.get_owner().get_property('ObjectToMove')
17+
18+
def tick(self, delta_time):
19+
if self.distance >= self.max_distance:
20+
return
21+
# find the next point on the spline
22+
next_point = self.spline.get_world_location_at_distance_along_spline(self.distance)
23+
self.actor_to_move.set_actor_location(next_point)
24+
self.distance += 100 * delta_time
25+
```

0 commit comments

Comments
 (0)