Dynamic properties
16 posts • Page 1 of 1
Dynamic properties
During creation of my xmas scene I've stuck on spawn objects with dynamic color.
I've trying many ways but still get an error message and solid color instead of brighting one.
Today I've solve this case and I think this will help you to make more visual stunning stuff
To spawn an object from console you can just type:
and this will works strange sometimes - only last laser will by dynamic, but if you try to do it in onCollide or onLaserHit you will fail completely
(it's kinda bug I think).
so the solution is to set color outside of spawning:
that's all.
I've trying many ways but still get an error message and solid color instead of brighting one.
Today I've solve this case and I think this will help you to make more visual stunning stuff
To spawn an object from console you can just type:
- Code: Select all
scene.addLaserPen{pos := app.mousepos; color := {[.5+sin(sim.time*10)/2,0,0,1]}}
and this will works strange sometimes - only last laser will by dynamic, but if you try to do it in onCollide or onLaserHit you will fail completely
so the solution is to set color outside of spawning:
- Code: Select all
(scene.addLaserPen{pos := app.mousepos}).color = {[.5+sin(sim.time*10)/2,0,0,1]}
that's all.
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Dynamic properties
WOW THAT'S AWESOME!
It's a (moderate) solution for the annoying thing that only let you make dynamic things for the newest spawned object.
Okay, it's not perfect but it's better than nothing
It's a (moderate) solution for the annoying thing that only let you make dynamic things for the newest spawned object.
Okay, it's not perfect but it's better than nothing

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Dynamic properties
Is there a way to incorporate a non updating variable into the color script that is based on the spawned object? That would make a huge difference.
I tryed using a pre defined controllerAcc value but it dosn't seem to register, it instead bases it (in real time) off the controllerAcc of the spawner.
I tryed using a pre defined controllerAcc value but it dosn't seem to register, it instead bases it (in real time) off the controllerAcc of the spawner.
- Code: Select all
(scene.addCircle({ pos := app.mousepos; controllerAcc := sim.time })).color ={[(sim.time - e.this.controllerAcc), 0, 0, 1]}
-

Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: Dynamic properties
try it with OnCollide or OnLaserHit. it works for me.
btw. there's a little mistake. don't type "e.this." otherwise your code won't work in any way.
btw. there's a little mistake. don't type "e.this." otherwise your code won't work in any way.

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Dynamic properties
Oh, I mean with the dynamic color, not just normal color changing.
That code seems to work with and without e.this, they both still depend on the controllerAcc of the spawner, not the individual circle.
That code seems to work with and without e.this, they both still depend on the controllerAcc of the spawner, not the individual circle.
-

Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: Dynamic properties
no it doesn't change the color if e.this. is in front of it. e.this/other only works in OnCollide. but in color there's nothing to call e. which results in an error.
but now i got your problem. it only changes the color if you press enter in the "color =" line (and if e.this. is removed). hmm i don't know a solution
but now i got your problem. it only changes the color if you press enter in the "color =" line (and if e.this. is removed). hmm i don't know a solution

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Dynamic properties
that will revolutionize scripts the same way as RaRaMalum did with the simple yet effective Oncollide := Oncollide ...
Jrv wrote:TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.
GTFO newfgt
-

RA2lover - Posts: 607
- Joined: Mon Aug 31, 2009 8:43 pm
- Location: Brazil
Re: Dynamic properties
yeah but there are a few problems if you want to make things with variables like versieon did above. it's a pity it doesn't work right. would be really cool if this can be fixed anyhow, too. 

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Dynamic properties
I can't get this to work
Here's what I've got
Here's what I've got
- Code: Select all
(Scene.addCircle({
controllerAcc := sim.time;
refractiveIndex := {((controllerAcc + 5) - sim.time) / 5};
drawBorder := false;
drawCake := false;
density := {refractiveIndex >= 0 ? {+inf} : {0.0}};
collideSet := 0;
materialVelocity := 0.0;
zDepth := +inf;
pos := e.pos;
radius := 768.0
})).color = {[1.0, 1.0, 1.0, ((controllerAcc + 5) - sim.time) / 5]};
-

Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Dynamic properties
As you can see - my method only works with 1 dynamic property.
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Dynamic properties
I have a way to solve these problems
:
I use this part of the script because if you save and reopen a scene with dynamics objects, the "object" variable won't exists anymore, then this will delete all dynamics objects :
This part of the script is very important when you delete dynamic object because if you don't reset dynamic variables, the script will keep running and after spawning a few more objects algodoo will run very slowly :
Here is the complete example :
(you can put this script in the onLaserHit var of a laser to see it working)
- Store the object into a variable
- Code: Select all
object = Scene.addCircle({
radius := 0.05;
pos := e.pos;
color := [1.0, 1.0, 0.0, 1.0];
drawcake := false;
drawborder := false
});
- Affect custom variables to the object
- Code: Select all
object.spawnTime := Sim.time;
object.lifeTime := 5;
object.fadeStart = object.spawnTime + object.lifeTime;
object.fadeTime = 1;
- Affect dynamic variables to the object
- Code: Select all
object.airFrictionMult = {(Sim.time == 0) ? {NaN} : {1.0}};
object.color = {[1, 1, 0, (object.fadeStart - Sim.time) / object.fadeTime]};
object.density = {
(Sim.time - object.spawnTime < object.lifeTime) ? {} : {
object.airFrictionMult = 1.0;
object.color = [0.0, 0.0, 0.0, 0.0];
object.density = 0.0
};
2.0
}
- You're done
- Code: Select all
object.airFrictionMult = {(Sim.time == 0) ? {NaN} : {1.0}};
- Code: Select all
object.airFrictionMult = 1.0;
object.color = [0.0, 0.0, 0.0, 0.0];
object.density = 0.0
Here is the complete example :
- Code: Select all
(e)=>{
object = Scene.addCircle({
radius := 0.05;
pos := e.pos;
color := [1.0, 1.0, 0.0, 1.0];
drawcake := false;
drawborder := false
});
object.spawnTime := Sim.time;
object.lifeTime := 5;
object.fadeStart = object.spawnTime + object.lifeTime;
object.fadeTime = 1;
object.airFrictionMult = {(Sim.time == 0) ? {NaN} : {1.0}};
object.color = {[1, 1, 0, (object.fadeStart - Sim.time) / object.fadeTime]};
object.density = {
(Sim.time - object.spawnTime < object.lifeTime) ? {} : {
object.airFrictionMult = 1.0;
object.color = [0.0, 0.0, 0.0, 0.0];
object.density = 0.0
};
2.0
}
}
(you can put this script in the onLaserHit var of a laser to see it working)
- REMqb
- Posts: 15
- Joined: Wed Dec 30, 2009 7:51 pm
- Location: France
Re: Dynamic properties
I want to be the first to congratulate you on your awesomeness for figuring this out!!!

EDIT
Ive tested this out, and this shows that Algodoo has a definite memory leak or something like that. The % of simulation time went down to less than 10% in less than a minute. Hope this can be fixed also.
EDIT
Ive tested this out, and this shows that Algodoo has a definite memory leak or something like that. The % of simulation time went down to less than 10% in less than a minute. Hope this can be fixed also.
-

Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: Dynamic properties
Yeah that's awesome. now after looking at it it's so obvious... but yeah the hard part is to get the idea. great work dude 

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Dynamic properties
You, sir, are the "winshit", as the young say.
.. ,__,_____
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial.
. / __.==--" - - - - - - - - ""
./#(-'
.`-' From http://www.ascii-art.de/. Modded by me to work in Arial.

a Mammoth wrote:be boring and interesting.
I didn't know you could go up 3.1.3! Thanks Mystery person!Mystery wrote:If you were jailbreaker you shouldn't have when't up the 3.1.3
-

Dakta - Posts: 417
- Joined: Sat Sep 12, 2009 4:36 pm
Re: Dynamic properties
Great!
This will help in some of my projects
This will help in some of my projects
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
-

Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
16 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest




