I trying to make a 3D train over rails, so it will begin slow, then gain velocity when the user press right key, when the player release the key, the train slow down then stop.
I don't know how to make use of lerp in this case (using PathFollow and offset value).
Any suggestions? Maybe an alternative way of doing this.
Thank you in advance!
obs.: I'm increasing the offset value of PathFollow, but I'd preffer use moveandslide and avoid making use of offset (loss of gravity and etc), but if this works with offset it's okay. When I use moveandslide acceleration/deacceleration and gravity is okay, but how does the train follow the path (x+z axis) and turn along the rail?
P.S.: Sorry about my english
I got this to work, but I'm not happy with the results.
- The train(hero) isn't starting in the first point of the path.
- The train is not standing still.It's moving backwards when stopped.
- The camera is also a crap when child of train or Path Follow. Seems to be unstable, trembling.
- Plus, the path created in Godot doesn't seem to works well, had to create a new one in Blender then import.
Download my project [Godot 3.1]: https://yadi.sk/d/egenpGXWtAEA8Q (Yandex disk cloud)
Here is the code:
var velocity = 0
var tempo =0
var acceleration = 0
onready var hero = $Path/PathFollow/hero
onready var pathf = $Path/PathFollow
velocity += (acceleration/tempo)*delta
pathf.offset += velocity*delta
# Stop it!
if velocity <= 0:
# Set max velocity
elif velocity >=8: