Topic was automatically imported from the old Question2Answer platform.
Asked By
rappa748
Hello!
I browsed a bunch of questions already but I found nothing near what I want. I’m building a race animation and I’m using tween to animate each car, which works fine.
But my next upgrade is to read a json/array with every lap time for each car and animate with those parameters. I looked at Tween and AnimatePlayer already but I couldnt figure out.
for CAR in racedata.keys():
var lapdata = racedata[CAR]
for LAP in lapdata.keys() :
var tweendata = lapdata[LAP]
$Tween.interpolate_property of CAR.position from tweendata["start"] to tweendata["end"] in tweendata["time"] seconds
Tween.start()
yield(Tween_finished)
This will animate all cars one after another. If You want to animate all cars simultanoulsy, You just need to make corroutine before iterating all cars in dictionary :
for CAR in racedata.keys():
animatelaps(racedata[CAR])
func animatelaps(lapdata):
for LAP in lapdata.keys() :
var tweendata = lapdata[LAP]
$Tween.interpolate_property of CAR.position from tweendata["start"] to tweendata["end"] in tweendata["time"] seconds
Tween.start()
yield(Tween_finished)