Change the color of an object when two other objects collide

For topics that don't fit under the other topics or forums.

Change the color of an object when two other objects collide

Postby lsnook » Mon Aug 17, 2020 6:54 pm

I change a variable state when two objects collide.
scene.my.variable=0
on_collison between object 1 and 2; scene.my.variable changes to 1.
When this happens, I want the color of a 3rd object to change.
lsnook
 
Posts: 3
Joined: Wed Aug 12, 2020 9:35 pm

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

Postby lsnook » Mon Aug 17, 2020 7:57 pm

Or, if there is another way to do this without using variables, that is fine too.
lsnook
 
Posts: 3
Joined: Wed Aug 12, 2020 9:35 pm

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

Postby DabTheDabr » Tue Sep 01, 2020 3:55 pm

lsnook wrote:I change a variable state when two objects collide.
scene.my.variable=0
on_collison between object 1 and 2; scene.my.variable changes to 1.
When this happens, I want the color of a 3rd object to change.

Good question :thumbup:

You can have the variable change in postStep.
It would look like this:
postStep:
Code: Select all
(e)=>{
scene.my.variable == 1 ? color = whateverYourColorIs : color = originalColor
}

Note that whateverYourColorIs and originalColor are not supposed to be in the code, and are meant to be substituted with your value of choice (in this instance, an array). Such is the nature of pseudocode.
User avatar
DabTheDabr
 
Posts: 5
Joined: Tue Aug 25, 2020 7:36 pm
Location: United States of America


Return to Algodoo in general

Who is online

Users browsing this forum: No registered users and 4 guests