[Closed] speed along path controller
Hi Guys,
I would like to know, can I use box height to affect the speed of the object with path constraint? I try to use float script controller. When the box height is 0, the speed should be 0, when height is 8, the speed should be 80km/h, I want to animate the speed in time.
In my scene, when I start to decrease the box height, the object stops and goes back, because the percent value decreases. Do you know the right formula, how to keep it increasing, even I change the box height back to lower values? here is scene file
thanks
Filip
Sorry, not really an answer for you off hand, but the immediate issue I can think of is the fact that the path controller’s percentage value deals with it’s position on the path and is not related to it’s speed. While I can see why you would be wanting to play with it. You might want to take a look at some of the spline ops. I can’t fully remember off hand, but I think there is some functionality there that might help.
Shane
Put a script at objects path controlers percent value:
-- velocity in meters/sec
-- v is box height
-- thePath is the path :)
-- this gives proper position at path when system unit is default inch and
-- display unit is meters, so 3.5m height gives 3.5 m/s
v * S / (curveLength thePath)
Thanks Decon, I’ve put there script already, I am able to change constant speed on the object… when I set speet to constant 60, 80, whatever, it goes and changes percentage. Now I would like to improve it with dynamic speed. I need somehow to call the current position percentage and add to it the speed formula, guess then I can get the real acceleration… currently I’am getting Illegal self-reference error.
cheers
filip
Hey, could you post your file or explain how you achieved it so ramping the value down doesn’t cause the object to reverse? Decon’s solution doesn’t seem to be working for me. Thank you!
You are going to have to add up the velocity per frame each time.
So…
v=calc velocity as shown.
pathPercent+=v
You will need to do this per frame so you need to work out the velocity based on your current frame rate or use ticks.
Thanks a lot for reply PEN,
what I finally did is the summary of all velocity values to the current frame, divided by current frame value.
“LEN = curveLength self.pos.controller.path
Trav = self.modifiers[#CarCTRL].Test_spinners.dist_spnr*1000T = currenttime
sum = 0for cx = 1 to T do
(
at time cx
sum = sum + ( self.modifiers[#CarCTRL].Test_spinners.speed_spnr / T)
)
sumPERCi = sum/3.6*S/LEN
D = Trav/LEN
PERC = PERCi+D”
Currently have another problem, I added wheel rotation derived from the path length, path percent and wheel radius. The problem is, that the wheels are turning sometimes inverse. I think, that the start rotation direction +/- of the wheels depends on the start car position/rotation. Do you know, how to solve this problem?
“LEN = curveLength (for x in refs.dependents(this) where isValidNode x collect x)[1].parent.pos.controller.path
PERC = (for x in refs.dependents(this) where isValidNode x collect x)[1].parent.pos.controller.Percent
RAD = (for x in refs.dependents(this) where isValidNode x collect x)[1].parent.modifiers[#CarCTRL].wheel_spnr
rot = (PERC/1000*LEN)/(RAD)”
Thanks
Filip
huh, it took me a while to grasp this !
ct = currenttime
dis = 0
-- next, for every frame let's calculate
-- the velocity and add them up
for i = 1 to ct do (
hoo = at time i $Box01.height
dis = dis + hoo
)
Thanks Paul and Filip
I already spent a whole day trying to figure this out, but it keeps on reversing whenever I the box height value is lowered…
theTime = currentTime
velo = boxHeight * S / (curveLength myPath)
myVal02 = 0
for o = 1 to theTime do
(
tempVal = at time o velo
myVal02 = myVal02 += tempVal
)
myVal02
shouldn’t val02 always be increasing in value instead of decreasing when the box height is lowered?
Hi, I’ve finnaly used attribute holder instead of box height.
here is my test scene
Open the scene, pick the car, run “add car path v1.5.ms” pick the path, then select front wheels and run “add wheel steering v1.5.ms” In modifier of the car is attribute holder where you can change wheel radius, distance of tracks, speed of the car and travelled distance on path.
known bug: wheel rotation is sometimes inverse:(
cheers
filip
jack, if it’s still fuzzy, take a look at this :
http://www.deconstudio.net/down/Adjust_speed_with_box_height_03.zip