Velocity Color Change (question)

About advanced scenes, and the Thyme scripting language used in Algodoo.

Velocity Color Change (question)

Postby jrderksen » Fri May 13, 2011 2:58 am

I've been trying to figure out how to make an object change color if another object reaches a certain velocity. Does anyone have any ideas as to how this could be done?
User avatar
jrderksen
 
Posts: 68
Joined: Wed Dec 22, 2010 4:50 am
Location: British Columbia, Canada

Re: Velocity Color Change (question)

Postby hiltropper » Fri May 13, 2011 12:56 pm

1.onHitbylaser=
Code: Select all
(e)=>{
    colorhsva = [colorhsva(0) + scene.my.vel, colorhsva(1), colorhsva(2), colorhsva(3)];
    colorhsva(0) > 358 ? {colorhsva = [0, colorhsva(1), colorhsva(2), colorhsva(3)]} : {colorhsva = colorhsva}
}


for the object with the color

2.onHitbylaser=
Code: Select all
    scene.my.vel = (e.pos - [textcolor(0), textcolor(1)]) / (sim.time - textcolor(2));
    textcolor = [e.pos(0), e.pos(1), sim.time, 1]


for the object which speed you want to see

maybe you have to double scene.my.vel or so, if you dont see such a great difference (scene.my.vel=scene.my.vel*2)

this is for a permanent color flow

if you want to trigger at a certain value (here:50) than it should look like

1.onHitbylaser=
Code: Select all
(e)=>{scene.my.vel >= 50? {colorhsva=[what color you want ]}:{colorhsva=what color it has before}}


the speed script stays at it is

let the objects permanent hit by lasers
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
hiltropper
 
Posts: 85
Joined: Mon Dec 20, 2010 12:02 pm
Location: Germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests