Mouse Triggered lasers and hinges

Post your tutorials here.

Mouse Triggered lasers and hinges

Postby TC42 » Sun Jan 30, 2011 5:06 am

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:

:arrow: 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 :D)

:arrow: 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"
}


:arrow: Now change the activationButton/buttonForward/buttonBack to "mouse_left" or "mouse_right"

:arrow: select your text and and again press Ctrl (command key on a Mac) + c

:arrow: 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.
Filesize: 11.46 kB
Comments: 2
download

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.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Mouse Controlled lasers and hinges

Postby Someone Else » Sun Jan 30, 2011 6:57 am

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.
Matthias Wandel is epic, in my humble opinion.
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Controlled lasers and hinges

Postby Rideg » Sun Jan 30, 2011 2:20 pm

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. ;)
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Mouse Controlled lasers and hinges

Postby TC42 » Sun Jan 30, 2011 3:00 pm

Please upload it! Now I can make a completely mouse controlled cannon! hehehehehe... :D
Before I forget, I forgot to mention that mouse controlled/mouse triggered lasers/hinges are phunlet-friendly.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Sun Jan 30, 2011 4:35 pm

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?
Matthias Wandel is epic, in my humble opinion.
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby Rideg » Sun Jan 30, 2011 11:10 pm

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. :problem:

Uploaded in a few mins.
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Mouse Triggered lasers and hinges

Postby Rideg » Sun Jan 30, 2011 11:30 pm

Sorry for the double post.

Here's the scene:
Rating: rated 6.2
Filesize: 9.9 kB
Comments: 6
Ratings: 4
download


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 :thumbup:
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Mon Jan 31, 2011 4:11 am

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.
Matthias Wandel is epic, in my humble opinion.
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby Rideg » Mon Jan 31, 2011 9:03 am

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.
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Mon Jan 31, 2011 7:31 pm

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.
Matthias Wandel is epic, in my humble opinion.
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby Rideg » Mon Jan 31, 2011 11:09 pm

Does material Veclocity exist in phun?
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Tue Feb 01, 2011 2:25 am

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...
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby TC42 » Tue Feb 01, 2011 2:59 am

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 :D
Last edited by TC42 on Tue Feb 01, 2011 3:33 am, edited 1 time in total.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Tue Feb 01, 2011 3:28 am

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.

Rating: rated 5
Filesize: 29.52 kB
Comments: 1
Ratings: 1
download


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...
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby TC42 » Tue Feb 01, 2011 3:35 am

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 :lol:
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Tue Feb 01, 2011 4:20 am

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?
Matthias Wandel is epic, in my humble opinion.
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby TC42 » Tue Feb 01, 2011 5:15 am

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) :crazy: and now my eyes have almost become completely square :D So I'll review it more tomorrow, when I'm actually paying some attention to what I'm typing.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Tue Feb 01, 2011 3:33 pm

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.
Matthias Wandel is epic, in my humble opinion.
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby TC42 » Thu Feb 03, 2011 12:08 am

On a different topic,

I've created not a mouse follower, but an object follower! Now I can make a completly autonomous machine gun :D 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 :D ...

Here's the scene, if you want it: [scene]51379[/scene]
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Mouse Triggered lasers and hinges

Postby cocolover76 » Mon May 09, 2011 11:57 pm

IT DOES NOT WORK! :cry:

If this helps, I am using Algodoo Phun Edition v5.28
Now, tell me how to do it with app.mousepos now.
Image
cocolover76
 
Posts: 135
Joined: Sun May 08, 2011 10:49 pm

Re: Mouse Triggered lasers and hinges

Postby TC42 » Tue May 10, 2011 2:46 am

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... 8-)


Or you could just modify Someone Else's version of Raydeg's version of Kilinich's mouse-pointer.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Mon May 16, 2011 3:45 am

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.
Matthias Wandel is epic, in my humble opinion.
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby TC42 » Mon May 16, 2011 3:53 am

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. :P

I want to see your version of the code... Hopefully, I will actually be able to understand it...
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Mouse Triggered lasers and hinges

Postby Someone Else » Tue May 17, 2011 2:59 pm

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... :think:

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...
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Mouse Triggered lasers and hinges

Postby cocolover76 » Sat Jun 04, 2011 6:56 pm

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.
Image
cocolover76
 
Posts: 135
Joined: Sun May 08, 2011 10:49 pm


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron