Mouse Triggered lasers and hinges
25 posts • Page 1 of 1
Mouse Triggered lasers and hinges
For those of you who didn't know, you can set a hinge to move, or a laser to fire with a left or right mouse click. Here's how:
First, create a hinge or laser. For the activation button/forward key/backward key, put in something like the up/down arrow, ect. Now select it and press Ctrl (command key on a Mac) + c (if you're using phun, this is not supported, so this won't work and you'll have to download my scene )
Open notepad OR textedit. Now press Ctrl (command key on a Mac) + v. You now can see just what makes up a hinge/laser. It should look something like this
Now change the activationButton/buttonForward/buttonBack to "mouse_left" or "mouse_right"
select your text and and again press Ctrl (command key on a Mac) + c
now go into algodoo, place your mouse where you want the hinge/laser and press Ctrl (command key on a Mac) + v.
Here's my example scene. If your not using a fixed context menu, this may really annoy you; one of the lasers fires with the right-click button.
Now you have your mouse-triggered laser/hinge. Enjoy it and create something awesome. And when you create something awesome, post it in this thread so others can more easily find it!
First, create a hinge or laser. For the activation button/forward key/backward key, put in something like the up/down arrow, ect. Now select it and press Ctrl (command key on a Mac) + c (if you're using phun, this is not supported, so this won't work and you'll have to download my scene )
Open notepad OR textedit. Now press Ctrl (command key on a Mac) + v. You now can see just what makes up a hinge/laser. It should look something like this
- Code: Select all
// FileVersion 14
// Phunlet created by Algodoo v1.8.5
FileInfo -> {
title = "Laser on mouse button";
author = "TC42";
version = 14
};
Scene.addHinge {
geom0 := -1;
world0pos := [-0.09375, 0.15625];
geom1 := 0;
geom1pos := [-0.09375, 0.15625];
ccw := false;
motorTorque := +inf;
impulseLimit := +inf;
opaqueBorders := true;
autoBrake := true;
motor := true;
motorSpeed := 1.5707964;
color := [0.014852926, 0.0, 0.29705852, 1.0];
distanceLimit := +inf;
entityID := 7505;
zDepth := 7.0;
size := 0.020154854;
buttonForward := "up";
buttonBack := "down"
}
Now change the activationButton/buttonForward/buttonBack to "mouse_left" or "mouse_right"
select your text and and again press Ctrl (command key on a Mac) + c
now go into algodoo, place your mouse where you want the hinge/laser and press Ctrl (command key on a Mac) + v.
Here's my example scene. If your not using a fixed context menu, this may really annoy you; one of the lasers fires with the right-click button.
Now you have your mouse-triggered laser/hinge. Enjoy it and create something awesome. And when you create something awesome, post it in this thread so others can more easily find it!
Last edited by TC42 on Sun Jan 30, 2011 3:02 pm, edited 1 time in total.
-
TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Mouse Controlled lasers and hinges
Hmm. I would think mouse control had a deeper meaning, rooted deep within the dark depths of... APP.MOUSEPOS!!!!
Okay, wow, that was weird. But I would call a mouse-controlled whatever something that either follows the mouse, or points at the mouse, or chases the mouse... You know.
But I would be really happy if any of those things could be phunlet-safe.
Oh, and one would think that there is some menu within Algodoo that will do the trick.
The Appearance menu > Box Text does the trick.
Okay, wow, that was weird. But I would call a mouse-controlled whatever something that either follows the mouse, or points at the mouse, or chases the mouse... You know.
But I would be really happy if any of those things could be phunlet-safe.
Oh, and one would think that there is some menu within Algodoo that will do the trick.
The Appearance menu > Box Text does the trick.
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: Mouse Controlled lasers and hinges
Someone Else wrote:...But I would be really happy if any of those things could be phunlet-safe...
Actually I've made a phunlet safe mouse aiming hinge. I can upload it in a few seconds if you'd like.
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Mouse Controlled lasers and hinges
Please upload it! Now I can make a completely mouse controlled cannon! hehehehehe...
Before I forget, I forgot to mention that mouse controlled/mouse triggered lasers/hinges are phunlet-friendly.
Before I forget, I forgot to mention that mouse controlled/mouse triggered lasers/hinges are phunlet-friendly.
-
TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Mouse Triggered lasers and hinges
Raydeg... Please upload your phunlet-safe mouse control thing...
Hmm... Does it have two motors straining against each other, and some gizmo alters the density of what the motors are connected to?
Would that even work?
Hmm... Does it have two motors straining against each other, and some gizmo alters the density of what the motors are connected to?
Would that even work?
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: Mouse Triggered lasers and hinges
Someone Else wrote:Raydeg... Please upload your phunlet-safe mouse control thing...
Hmm... Does it have two motors straining against each other, and some gizmo alters the density of what the motors are connected to?
Would that even work?
No motors. It only works in Algodoo though.
Uploaded in a few mins.
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Mouse Triggered lasers and hinges
Sorry for the double post.
Here's the scene:
It uses a laser and a material velocity to turn the wheel. Adjust the torque by adjusting the wheel's and the boxe's friction. I'll upload a new file with theese grouped together.
Hope this helped
Here's the scene:
It uses a laser and a material velocity to turn the wheel. Adjust the torque by adjusting the wheel's and the boxe's friction. I'll upload a new file with theese grouped together.
Hope this helped
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Mouse Triggered lasers and hinges
Interesting... but I do not understand your code. Explanation please?
I might copy the code onto an alternating collider. To make it safe for Phun.
I might copy the code onto an alternating collider. To make it safe for Phun.
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: Mouse Triggered lasers and hinges
Someone Else wrote:Interesting... but I do not understand your code. Explanation please?
I might copy the code onto an alternating collider. To make it safe for Phun.
Actually I don't fully understand the code. I borrowed Kilinich's mouse following code due to my own code ain't so accurate.
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Mouse Triggered lasers and hinges
Hmm...
Could you give me a link to Kilinich's thing?
I will now try to figure it out. And make it work in Phun. But I will probably fail.
Could you give me a link to Kilinich's thing?
I will now try to figure it out. And make it work in Phun. But I will probably fail.
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: Mouse Triggered lasers and hinges
Does material Veclocity exist in phun?
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Mouse Triggered lasers and hinges
Rideg wrote:Does material Veclocity exist in phun?
I dunno. Too lazy to check. But, I will now FINALLY be able to work on my collision-i-fication.
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: Mouse Triggered lasers and hinges
Someone Else wrote:Rideg wrote:Does material Veclocity exist in phun?
I dunno. Too lazy to check. But, I will now FINALLY be able to work on my collision-i-fication.
Actually, I think it does; vel:=e.normal * velocity works in Phun, that's how one of my scripted machine guns works
Last edited by TC42 on Tue Feb 01, 2011 3:33 am, edited 1 time in total.
-
TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Mouse Triggered lasers and hinges
In any case, it works in Algodoo. And so does my kinda large collision-based version of Raydeg's thing.
Hmm, I cannot find it in the Algobox upload browser.
Man, that was awkward. I had to save it into my collab folder so I could find it to upload it.
And how come my thumbnails are always off a bit?
Hmm, I cannot find it in the Algobox upload browser.
Man, that was awkward. I had to save it into my collab folder so I could find it to upload it.
And how come my thumbnails are always off a bit?
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: Mouse Triggered lasers and hinges
Someone Else wrote:
And how come my thumbnails are always off a bit?
Hehehehehe... My screen has a brand/logo directly in the center of the frame... Just line it up, make sure the zoom is right... and I almost always have the perfect thumbnail. Just put a small post-it note in the center of the screen and use that
-
TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Mouse Triggered lasers and hinges
Or select some of the geoms, go into any of their menus, and click the eyeball button. Probably.
But what do you think of my mouse following thingy?
But what do you think of my mouse following thingy?
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: Mouse Triggered lasers and hinges
It looks good! I have no idea how any of anyones mouse-followers actually work, so I can't really comment on that aspect. It is still really good for being collision based, although it seems to overshoot a tiny bit, then move to the correct position.
I'll post my official comments tomorrow, when I have more time to look at it in-depth. I don't have time to do that right now; I had a ton of homework, been typing since 3:00 PM (It's now 10:00 PM) and now my eyes have almost become completely square So I'll review it more tomorrow, when I'm actually paying some attention to what I'm typing.
I'll post my official comments tomorrow, when I have more time to look at it in-depth. I don't have time to do that right now; I had a ton of homework, been typing since 3:00 PM (It's now 10:00 PM) and now my eyes have almost become completely square So I'll review it more tomorrow, when I'm actually paying some attention to what I'm typing.
-
TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Mouse Triggered lasers and hinges
Really, I don't know how it works, either.
I just copied Raydeg's code, changed an e.geom.materialValocity into a materialVelocity,
added an IF statement,
and added an alternating collider.
In retrospect, maybe I should have just used two friction boxes.
I just copied Raydeg's code, changed an e.geom.materialValocity into a materialVelocity,
added an IF statement,
and added an alternating collider.
In retrospect, maybe I should have just used two friction boxes.
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: Mouse Triggered lasers and hinges
On a different topic,
I've created not a mouse follower, but an object follower! Now I can make a completly autonomous machine gun And I can make it fire only when it is aimed at its target and the mouse is clicked. Now I just need to add the manual override ...
Here's the scene, if you want it: [scene]51379[/scene]
I've created not a mouse follower, but an object follower! Now I can make a completly autonomous machine gun And I can make it fire only when it is aimed at its target and the mouse is clicked. Now I just need to add the manual override ...
Here's the scene, if you want it: [scene]51379[/scene]
-
TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Mouse Triggered lasers and hinges
IT DOES NOT WORK!
If this helps, I am using Algodoo Phun Edition v5.28
Now, tell me how to do it with app.mousepos now.
If this helps, I am using Algodoo Phun Edition v5.28
Now, tell me how to do it with app.mousepos now.
- cocolover76
- Posts: 135
- Joined: Sun May 08, 2011 10:49 pm
Re: Mouse Triggered lasers and hinges
Of course it doesn't work in Phun, it uses lasers! To make/understand it in phun, I think you must either know trig or calculus (so you can use PID equation). I don't *officially* know either, but I'm working on it... I know how to use Sine, Cosine, Tangent and Theda so far...
Or you could just modify Someone Else's version of Raydeg's version of Kilinich's mouse-pointer.
Or you could just modify Someone Else's version of Raydeg's version of Kilinich's mouse-pointer.
-
TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Mouse Triggered lasers and hinges
If I were to make a Phun-safe object follower (I won't), I would use a beacon (let me know if you don't know what that is) to save the e.pos of the object in scene.my.pos, and change app.mousePos to scene.my.pos in my version of Raydeg's version of Kilinich's mouse pointer.
Come to think of it, I have thought of a way to fix Raydeg's follower, so it would not spaz when the mouse is on the perimeter of the circle.
It would use two lasers, and find the position of the center of the circle by averaging those two positions. It would use e.normal of one of the lasers to give the direction the unit is pointing, and I would try to build my own code off of that, if that does not work, I will use my version of Raydeg's version of Kilinich's code.
Come to think of it, I have thought of a way to fix Raydeg's follower, so it would not spaz when the mouse is on the perimeter of the circle.
It would use two lasers, and find the position of the center of the circle by averaging those two positions. It would use e.normal of one of the lasers to give the direction the unit is pointing, and I would try to build my own code off of that, if that does not work, I will use my version of Raydeg's version of Kilinich's code.
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: Mouse Triggered lasers and hinges
If I were to make a Phun-safe object follower (I won't), I would use a beacon (let me know if you don't know what that is) to save the e.pos of the object in scene.my.pos, and change app.mousePos to scene.my.pos in my version of Raydeg's version of Kilinich's mouse pointer.
That is exactly what I did in one of my helicopter games, except in algodoo.
I want to see your version of the code... Hopefully, I will actually be able to understand it...
-
TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Mouse Triggered lasers and hinges
I haven't built it yet.
Let me think here...
The entirety of the code would be in the circle, and the majority of it would be in an IF statement activated when e.laser.color == [1, 0, 0, 2].
It will use some basic algebra and two lasers to find the position of the center of the circle. This would be done by saving the e.pos of the green laser in textureMatrix, and averaging that with the e.pos of the red laser. I could accomplish this with one laser by subtracting a multiple of e.normal from e.pos, but that is not scalable.
It will then use some trig to find the angle between the center and the point in question, then use the same trig to find the angle buried within e.normal.
Come to think of it, I already have that trig code on hand. At least, for the e.normal part... I'm not sure if it will work when the vector in question is not a unit vector. Then again, I did see a suitable math code on Link's Math Functions sticky...
Anyway, it will then find the difference between the two angles, maybe multiply it by -1, and plug the result into materialVelocity.
Let me think here...
The entirety of the code would be in the circle, and the majority of it would be in an IF statement activated when e.laser.color == [1, 0, 0, 2].
It will use some basic algebra and two lasers to find the position of the center of the circle. This would be done by saving the e.pos of the green laser in textureMatrix, and averaging that with the e.pos of the red laser. I could accomplish this with one laser by subtracting a multiple of e.normal from e.pos, but that is not scalable.
It will then use some trig to find the angle between the center and the point in question, then use the same trig to find the angle buried within e.normal.
Come to think of it, I already have that trig code on hand. At least, for the e.normal part... I'm not sure if it will work when the vector in question is not a unit vector. Then again, I did see a suitable math code on Link's Math Functions sticky...
Anyway, it will then find the difference between the two angles, maybe multiply it by -1, and plug the result into materialVelocity.
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: Mouse Triggered lasers and hinges
I found out how to use mouse triggered hinge in Phun!
I will release it soon.
Basically, in Phun, when you use mouse_left or mouse_right, no matter if you put it for forward or backward, it wants to go the direction of the motor for some reason.
I will release it soon.
Basically, in Phun, when you use mouse_left or mouse_right, no matter if you put it for forward or backward, it wants to go the direction of the motor for some reason.
- cocolover76
- Posts: 135
- Joined: Sun May 08, 2011 10:49 pm
25 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest