Change the color of an object when two other objects collide

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

Change the color of an object when two other objects collide

Postby lsnook » Tue Aug 18, 2020 6:14 pm

When object 1 collides with object 2, I want to change the color of object 3.
My attempt was to create a variable, scene.my.variable=0, entered into the console (F11).
Next, OnCollision between object 1 and 2, set scene.my.variable=1.

Where in object 3's properties can I insert an "IF" statement to change the color of object 3?
(e)=>{{scene.my.variable=1}?{color=[0,0,1,1]}:{color=[1,0,0,1]}}
lsnook
 
Posts: 3
Joined: Wed Aug 12, 2020 9:35 pm

Re: Change the color of an object when two other objects collide

Postby FLO » Mon Aug 31, 2020 6:17 am

Put this in object 1 at onCollide:

Code: Select all
(e)=>{
    scene.my.change = true
}


Put this in object 3 at postStep:

Code: Select all
(e)=>{
    scene.my.change ? {
        color = [0.0, 0.0, 1.0, 1.0]
    } : {}
}
I make mainly games.
best games
best game engine
User avatar
FLO
 
Posts: 16
Joined: Thu Aug 18, 2016 5:11 pm
Location: germany


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests

cron