This method is suitable for straightforward motion but if you change the direction it needs a little math to calculate a trajectory and I am not very good at math :)
A
aphexx
hi, this is very cool! although i'm no scripter at all :)
ausn
I figured out this method:
prePos = at time (currentTime - 1t) self.pos
nextPos = at time (currentTime + 1t) self.pos
d = distance prePos nextPos
v = d*4800/2 -- unit:inch/s
v = v*2.54/1000 -- unit:m/s
v = v*60*60/1000 -- unit:km/h
It could be precise enough for most circumstances.
And a friend showed me this method:
prePos = at time (currentTime - 1t) self.pos
curPos = self.pos
nextPos = at time (currentTime + 1t) self.pos
d1 = distance prePos curPos
d2 = distance curPos nextPos
d = (d1+d2)/2
v = d*4800/2 -- unit:inch/s
v = v*2.54/1000 -- unit:m/s
v = v*60*60/1000 -- unit:km/h
Comments (3)
Comment policy
This method is suitable for straightforward motion but if you change the direction it needs a little math to calculate a trajectory and I am not very good at math :)
hi, this is very cool! although i'm no scripter at all :)
I figured out this method:
prePos = at time (currentTime - 1t) self.pos
nextPos = at time (currentTime + 1t) self.pos
d = distance prePos nextPos
v = d*4800/2 -- unit:inch/s
v = v*2.54/1000 -- unit:m/s
v = v*60*60/1000 -- unit:km/h
It could be precise enough for most circumstances.
And a friend showed me this method:
prePos = at time (currentTime - 1t) self.pos
curPos = self.pos
nextPos = at time (currentTime + 1t) self.pos
d1 = distance prePos curPos
d2 = distance curPos nextPos
d = (d1+d2)/2
v = d*4800/2 -- unit:inch/s
v = v*2.54/1000 -- unit:m/s
v = v*60*60/1000 -- unit:km/h