Page 1 of 1

magnetic car crane

PostPosted: Mon Dec 21, 2009 11:25 pm
by telemole
Hi folks,

I am a programmer - but new to Algodoo.. I am building some basic games for my 4 and 6 year old kids.

I want to create a crane they operate that works like a giant magnet - picking up cars when they get the magnet over car and 'activate' the magnet somehow... then drop it again when the magnet is 'de-activated'

Anyone have thoughts on how to do this? and perhaps a nice little sample I can pick to pieces to start to understand this code?

thanks in advance!

Cheers,
Sean

Re: magnetic car crane

PostPosted: Tue Dec 22, 2009 2:36 am
by Ian151
Rating: rated 5.1
Filesize: 37.31 kB
Comments: 1
Ratings: 2
download


Here is a scene that should help. This is what I did...

Seeing how you seem to have Algodoo, I made it with lasers. One laser turns on the magnet, another one shuts it off.

The laser that turns it on...

Code: Select all
(e)=>{e.geom.refractiveindex == 1.1 ? {e.geom.attraction = e.geom.controlleracc} : {}}


The only part you need to really payattention to is the part that says e.geom.attraction =
That part will tell the geometry to change attraction. I set it to change the attraction to whatever the geometries controller acc is, or e.geom.controlleracc.

This is for laser collisions, e.geom and e.laser. for other collisions, such as object and object, it would be e.this or e.other.

Re: magnetic car crane

PostPosted: Tue Dec 22, 2009 3:31 am
by telemole
this is fantastic!

Almost exactly what I wanted! Now if I can just be a further pain and ask WHERE you set the laser controls - i was unable to find the script with the key bindings and the statements you quoted...

I did play with the attraction level and also noticed that it is only in effect on matching collision groups - which is perfect.

Can't wait to play more with this! If you can give me a greater understanding I'd really appreciate it! Thanks for this!

Sean

Re: magnetic car crane

PostPosted: Wed Dec 23, 2009 12:06 am
by Ian151
The lasers are partially hidden above the red magnet. It's where the boxes are all packed together above the magnet. Select the entire attachment, click selection... And then select only lasers from there. Then bring them to the front. I'm glad you found my magnet to be of good use :)

Re: magnetic car crane

PostPosted: Wed Dec 30, 2009 6:27 pm
by Bronie12345
make sure you have algodoo in advanced mode, to see everything...