Change the color of an object when two other objects collide
2 posts • Page 1 of 1
Change the color of an object when two other objects collide
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]}}
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
Put this in object 1 at onCollide:
Put this in object 3 at postStep:
- 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]
} : {}
}
-
FLO - Posts: 16
- Joined: Thu Aug 18, 2016 5:11 pm
- Location: germany
2 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests