On-rails Movement behavior (n00b question)

For questions about using Classic.

Post » Fri Nov 19, 2010 9:09 pm

I've decided to make a game that features trains, which means it would be really handy to be able to create a behavior that ties objects to a track and allows the movement of an object to be characterised entirely by its speed and how far along a given track it is. The basic idea is to define rails as some parametric curve (say, a spline), and then store only a train's speed and distance along this curve and at every frame decode the parametric position into the Cartesian position that the sprite gets drawn at. Once that's done it's fairly easy to add fancy behavior like acceleration, slowing down for corners and slopes and whatever.

My question is is it worth writing an entire behavior for this, or is simply calling a Python script that does the calculations every frame the way forward? As I understand it there's no way of implementing this kind of movement without some kind of script.
B
1
G
2
Posts: 1
Reputation: 627

Post » Fri Nov 19, 2010 9:42 pm

Pretty much anything that can be done with a script can be done with events. This can be done with events.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Fri Nov 19, 2010 9:47 pm

There's lerp, cubic, etc, or an existing behavior.
[url:ztl30peb]http://www.scirra.com/forum/viewtopic.php?f=2&t=5693&hilit=path+behavior[/url:ztl30peb]
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sun Nov 21, 2010 8:21 pm

Or what you can do easily (If you are looking from a top view) is give it bullet movement, and put an invisible block at corners.

Train>On collision with>Turn_right_square:Train=Turn 90*
B
2
G
2
Posts: 30
Reputation: 710


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests