change density for a limited period only
5 posts • Page 1 of 1
change density for a limited period only
Hey,
is it possible to change something like the density just for a limited period?
e.g.
onHitByLaser = (e)=>{density = 0.005}
but after 5 seconds the density should return to 2.0
MyMan
is it possible to change something like the density just for a limited period?
e.g.
onHitByLaser = (e)=>{density = 0.005}
but after 5 seconds the density should return to 2.0
MyMan
- MyMan
- Posts: 4
- Joined: Mon Sep 16, 2013 6:59 pm
Re: change density for a limited period only
Yes, it is possible. Is it ok if it uses scene.my.* variables, or not?
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: change density for a limited period only
Yes
it is ok
But then you have to tell me every little step.
I have no experience with own variables
it is ok
But then you have to tell me every little step.
I have no experience with own variables
- MyMan
- Posts: 4
- Joined: Mon Sep 16, 2013 6:59 pm
Re: change density for a limited period only
Okay, I'll try to explain:
And there you go. Whenever you want to change the density of that object, change the value of scene.my.densityChange. After 1 second, the density will return to 2.
The red "1" inside the code is the number of seconds it takes to change the density back to 2.
- Open the console by pressing the "~" button.
- Type into the console: scene.my.densityChange = 2
- Open the script menu of the object where you want to change the density.
- Remove the "2.0" from the density value inside the script menu, and type: {scene.my.density}
- Change the controllerAcc of the object to 0.
- In the onHitByLaser value, type:
(e)=>{
scene.my.densityChange != 2 ? {
sim.time - controllerAcc >= 1 ? {
scene.my.density = 2
} : {}
} : {
controllerAcc = sim.time
}
}
And there you go. Whenever you want to change the density of that object, change the value of scene.my.densityChange. After 1 second, the density will return to 2.
The red "1" inside the code is the number of seconds it takes to change the density back to 2.
Phundementalism?
Ain't nobody got thyme fo dat.
Ain't nobody got thyme fo dat.
-

mold999 - Posts: 225
- Joined: Sun Jan 02, 2011 1:35 am
- Location: [176436, 3763234]
Re: change density for a limited period only
If you don't want to use scene.my variables, try this:
On the box you want to change the density change these two pieces of code..
And also
On the box you want to change the density change these two pieces of code..
- Code: Select all
onHitByLaser := (e)=>{
density = 1;
e.this.controllerAcc = sim.time
}
And also
- Code: Select all
update := (e)=>{
sim.time - controllerAcc >= 2 ? {
density = 2
} : {}
}
- MrGlinzz
- Posts: 13
- Joined: Tue Mar 19, 2013 11:51 pm
5 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests



