"Float Expression" to control a light

Roger.Bastow
Participant
Participant

"Float Expression" to control a light

Roger.Bastow
Participant
Participant

Hi, this forum is brilliant 🙂

 

I now have a “Dummy” object and I want to rotate on “X” axis.

As it rotates, I want it to turn a light on and off at predefined angels.

I put a Float Script on X axis of my “Dummy” object and wrote this:

 

dummyRotation = $.rotation.x

if dummyRotation >= 10.0 and dummyRotation < 12.0 then

(

Spark001.Multiplier = 1.0 -- Turn on Spark001

)

else

(

Spark001.Multiplier = 0.0 -- Turn off Spark001

)

 

But when I Evaluate, I get –Unknown property: “multiplier” in undefined? Do I need a Variable?

Regards

Rog 😊

0 Likes
Reply
364 Views
4 Replies
Replies (4)

leeminardi
Mentor
Mentor

I'm not familiar with spark lights but this is something that you should easily be able to do with a Wire Parameter.

 

For example,  when  the teapot angle in the following is >= 10° and < 12° the intensity is 1500, if not it's 0.

leeminardi_0-1700406814174.png

 

 

lee.minardi
0 Likes

istan
Advisor
Advisor

I think, the error message is clear: "Unknown property: “multiplier” in undefined"

You have to find answers for these questions:

Is "Spark001" a variable you already defined somewhere else or is it undefined?

Is "Multiplier " a property of the object ?

 

0 Likes

Roger.Bastow
Participant
Participant
0 Likes

leeminardi
Mentor
Mentor

@Roger.Bastow I should have noted that if it is possible that the object will rotate more than one full revolution then the modulo function "mod" should be used to always get an angle between 0 and 360.  Although the Transform Type-in may show an angle less than 360 it could be the remainder of the angle dividied by 360.

 

The wire expresson should be something like:

if(((mod (radToDeg(X_Rotation)) 360) >= 10) and ((mod (radToDeg(X_rotation)) 360) < 12)) then 1500 else 0

 

lee.minardi
0 Likes

Type a product name