[Closed] Float Script for Brake Lights when car moves/stops
HI Anyway to have car lights change OFF/ON (by changing blend materials or material id 1 – 2 ) when car moves or stops. There is a scrip for this along the path but our cars will move in space without path constraint. (city traffic 2) Anyway to have material id change to 2 when car slows down/ stops or 1 when car starts moving/moves Thank you!
Thread to path constraint car lights http://forums.cgsociety.org/showthread.php?t=640818
This works with path constraint only.
braking = .96
theCar = $MaroonSedan
PositionNext = at time (currentTime + 1) theCar.position.controller.percent
PositionCurrent = at time currentTime ( theCar.position.controller.percent )
PositionPrevious = at time (currentTime – 1) ( theCar.position.controller.percent )
travel = abs (PositionNext – PositionCurrent)
travelPrev = abs (PositionCurrent – PositionPrevious)
–ID = 1
if (travel <= 0.01) then (ID = 2 ) – standing still
–else (
else if ((travel / travelPrev) < braking) then ( ID = 2 ) – braking
else( ID = 1 ) – coasting–)
Instead of measuring path controller percentages, you’ll just need to measure world space position changes.
Thank you
do you know what should I type instead of theCar.position.controller.percent
I am not good at scripting at all
Should be able to simply change it to:
theCar.position
That will return the world space position.
Thank you! Unfortunately I get some ABS error . I create car and called it car2 and linked the lights. Any help is welcome. Thank you!
braking = .96
theCar = $car2
PositionNext = at time (currentTime + 1) theCar.position
PositionCurrent = at time currentTime ( theCar.position )
PositionPrevious = at time (currentTime – 1) ( theCar.position )
travel = abs (PositionNext – PositionCurrent)
travelPrev = abs (PositionCurrent – PositionPrevious)
–ID = 1
if (travel <=0.001 ) then (ID = 2 ) – standing still
–else (
else if ((travel / travelPrev) < braking) then ( ID = 2 ) -- braking
else( ID = 1 ) – coasting
–)
Thank you ! it worked! Even with madcar 3 plugin
and i have one last question maybe you know how to. I use octane and instead of material ID change I would like to use octane mix material amount. Amount 1 – light is ON, 0 light is OFF since city traffic 2 plugin works best when you have 5 parts of the car body (body and 4 wheels) and unfortunately material id changes all car body IDs therefore lights must be detached and linked.
Anyway to have this float scrip change octane material mix amount value and not material ID?
Thank you again!
Scripts can be used to access basically any property of anything within max.
What you’ll need to figure out is the underlying object (Octane material) you want to change the property for, and the property name.
I don’t use Octane myself, so I’m not sure what the property name for the mix value is, but you can probably figure it out by doing something like:
--after assigning the material to your object, click your object and run:
showproperties $.material
That will give you a list of property names for that material in the maxscript listener. Use that information within your script to change the value procedurally. Ultimately it’ll be something like:
theCar.material.mix_amount
Thanks a lot for explaining and all your help. it really helped a lot.
By the way can you apply this script to multiple cars at once or there is no way to do it since I have to use theCar = $car2 per 1 car only and change name for each car brake light.
Thank you
you can wrap your code with foreach loop
for obj in selection do
(
theCar = obj
...
...
)
Hi Can anyone help me change material ID to Texture amount value.
This is what I found out about octane mix texture
.material1 : material
.material2 : material
.amount_input_type : integer
.amount_value : float
.amount_color : RGB color
.amount_tex : texturemap
.displacement : texturemap
So I tried to change this bottom part instead of ID=2 to theCar.material.amount_value and get an error. Not sure if it is even correct at all. The float script was added to the amount value in the texture. Hopefully it is the right placement Thank you
[b]braking = .96
theCar = $RC3
PositionNext = at time (currentTime + 1) theCar.position
PositionCurrent = at time currentTime ( theCar.position )
PositionPrevious = at time (currentTime – 1) ( theCar.position )
travel = length (PositionNext – PositionCurrent)
travelPrev = length (PositionCurrent – PositionPrevious)
–theCar.material.amount_value = 1
if (travel <=0.1 ) then (theCar.material.amount_value = 1 ) – standing still
–else (
else if ((travel / travelPrev) < braking) then ( theCar.material.amount_value = 1 ) -- braking
else( theCar.material.amount_value = 0 ) – coasting
–)
[/b]