Changing Spring Constant On Laser Collide?
15 posts • Page 1 of 1
Changing Spring Constant On Laser Collide?
I'm wondering how to change a spring's constant with lasers. I know how to do it with spring length, but I don't know the code to do it for constant. any help would be greatly appreciated : )
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
lethalsquirl wrote:I'm wondering how to change a spring's constant with lasers. I know how to do it with spring length, but I don't know the code to do it for constant. any help would be greatly appreciated : )
I don't believe that it's possible because you would need to have collision layers, and springs do not have collision layers. How were you able to change spring length with a laser? I didn't think that was possible either without collision layers!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Changing Spring Constant On Laser Collide?
I set spring length to
{
scene.my.lenght
}
and set an object that will collide with laser to
(e)=>{
scene.my.lenght = XX
}
An example of this.
I want to try this again, but have points in the piston stroke where the spring constant goes to 0 to prevent the sloppy movement in between the spring length changes.
{
scene.my.lenght
}
and set an object that will collide with laser to
(e)=>{
scene.my.lenght = XX
}
An example of this.
I want to try this again, but have points in the piston stroke where the spring constant goes to 0 to prevent the sloppy movement in between the spring length changes.
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
Typing
into the spring's script menu didn't work?
The variable for spring length is called "length", and the variable for spring constant is similarly called "constant". You can use exactly the same code structure to control either (or any variable in any object, for that matter) via scene.my variables.
Did you misspell something?
- Code: Select all
constant = {scene.my.constant}
into the spring's script menu didn't work?
The variable for spring length is called "length", and the variable for spring constant is similarly called "constant". You can use exactly the same code structure to control either (or any variable in any object, for that matter) via scene.my variables.
Did you misspell something?
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Changing Spring Constant On Laser Collide?
Exactly what I thought, but when I press enter, it just goes clears back to the default value. What's strange is I just realized that
constant = {scene.my.length} actually works, but then the laser collide effects both length and constant at the same time, and I don't want that.
constant = {scene.my.length} actually works, but then the laser collide effects both length and constant at the same time, and I don't want that.
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
I defined scene.my.constant, and then used it as the variable for the spring's constant, and it works just fine for me. I put a simple script in the laser which increments the constant value while the laser is firing. No problems here!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Changing Spring Constant On Laser Collide?
For some reason when I try to add scene.my.constant to the constant box, I press enter and it just goes back to the default value.
The same thing is now happening with length. I type it in, press enter, and it just goes back to default.
It was just working for length. I'm pretty sure I'm typing it right : /
The same thing is now happening with length. I type it in, press enter, and it just goes back to default.
It was just working for length. I'm pretty sure I'm typing it right : /
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
Could you maybe send me your scene so I can see how you typed it out?
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
lethalsquirl wrote:For some reason when I try to add scene.my.constant to the constant box, I press enter and it just goes back to the default value.
The same thing is now happening with length. I type it in, press enter, and it just goes back to default.
It was just working for length. I'm pretty sure I'm typing it right : /
I believe I know what the problem is. Before you can add {scene.my.constant} to the spring's constant value window, you need to first DEFINE it! So, either in the console, or in the text box in the upper left corner of the script menu, enter scene.my.constant:= 10 ( or whatever initial value that you want to give it).
Then hit Enter. After defining the variable, you should be able to add it to the spring constant value window without it reverting back to the default value. Try that and let me know if it works.
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Changing Spring Constant On Laser Collide?
Oh man, I totally forgot about that part. It's been a while since I made that first one, I forgot the entire process. I'm still just a thyme noob
That was my problem all along
Thanks for the help though, I think I got this now
That was my problem all along
Thanks for the help though, I think I got this now
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
I'm still a little confused but im not even sure how to explain. so when I define it, how do I then get the spring to change from what I defined it to by lasers. I type scene.my.constant:= 500 for example, then I type {scene.my.constant} in the constant box, and the constant changes to 500 of course, but when I set a box to collide with a laser to onCollide = (e)=>{scene.my.constant = 1}
nothing happens.
nothing happens.
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
if you're triggering it with a lazer, make sure you're using "OnLaserHit" and not "onCollide"!
OnLaserHit - laser to geom collisions
OnCollide - geom to geom collisions
I can only see that possible issue based on what you have wrote, as the code example works fine.
OnLaserHit - laser to geom collisions
OnCollide - geom to geom collisions
I can only see that possible issue based on what you have wrote, as the code example works fine.
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Changing Spring Constant On Laser Collide?
Yep that was the issue. *facepalm* I feel like a total noob. I guess we all gotta learn somehow xD
Thanks for the help!
Thanks for the help!
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
One last thing though, is it possible to change the constant, AND length of 1 spring at the same time?
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
Re: Changing Spring Constant On Laser Collide?
Never mind, I figured it out 
-

lethalsquirrel - [ex-squirl]
- Posts: 54
- Joined: Fri Sep 11, 2009 5:03 am
15 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests




