Browse Search Popular Register Upload Rules User list Login:
Search:
Proximity Detection Tutorial

Image:
screenshot of the scene

Author: Xray

Group: Default

Filesize: 282.58 kB

Date added: 2013-12-07

Rating: 5.6

Downloads: 888

Views: 447

Comments: 14

Ratings: 2

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

There is an alternative method of detecting when geometries are in contact with each other besides using collisions (onCollide script). This scene shows a simple script that detects when another geometry OR the mouse cursor, are very close to a circle that contains the script. There are three versions of the script, one for each different geometry (and the cursor position) being monitored. When the distance between the black circle and either of those items being monitored is closer than the diameter of the black circle, the color of the black circle will change to either Red, White, or Blue. Keep in mind that the xy position value (pos) is the location of the CENTER point of the circle, not the outer edge.

This script can be very handy for detecting collisions between geometries that cannot be triggered using the traditional onCollide script.

By the way, there are other slightly different versions of this script that other people have used in their scenes. This is just one example, but you can find different and even better versions of it in past scenes by kilinich, s_noonan, and other very talented software guru's. You can also find tutorials in the Algodoo forum. Also please note that this script will only work for circles. If you want to detect boxes or polygons, then the script will need to be quite different, which you can find in the forum. Here is an EXCELLENT tutorial by kilinich: MouseOver Effects

Leave comments if you have questions about this scene and I'll try my best to answer them.
Last edited at 2013/12/07 05:45:58 by Xray
Please log in to rate this scene
edit
Similar scenes
Title: (CONTROLLER) What it's Like to be a Machine
Rating: 5
Filesize: 15.93 kB
Downloads: 1115
Comments: 0
Ratings: 1
Date added: 2022/02/27 00:54:02
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Rocket with proximity fuse
Rating: 6.5
Filesize: 42.81 kB
Downloads: 1858
Comments: 3
Ratings: 4
Date added: 2010/11/14 11:04:49
Made with: Phun
Rating: rated 6.5
download
Title: Parking Lot Challenge
Rating: 6.1111
Filesize: 84.52 kB
Downloads: 3845
Comments: 15
Ratings: 3
Date added: 2024/12/03 22:40:17
Made with: Algodoo v2.2.2
Rating: rated 6.1
download
Title: KITTON: The Tutorial
Rating: 5
Filesize: 208.78 kB
Downloads: 254
Comments: 1
Ratings: 1
Date added: 2025/02/22 09:00:04
Made with: Algodoo v2.2.3
Rating: rated 5
download
Title: Easy Rocket Tutorial >Youtub
Rating: 5.75
Filesize: 44.42 kB
Downloads: 840
Comments: 0
Ratings: 4
Date added: 2009/02/28 16:03:47
Made with: Phun
Rating: rated 5.8
download
Title: Escape the lab tutorial
Rating: 5.625
Filesize: 325.33 kB
Downloads: 642
Comments: 0
Ratings: 2
Date added: 2011/01/09 09:06:28
Made with: Phun
Rating: rated 5.6
download
Interesting
Nice tutorial, well documented, straight forward, and concise design work. That didn't stop me from messing around with it.

I made the following modification to my copy which mixes the colors on multiple overlaps:

_proximity := {
radius > math.vec.dist(pos, scene.my.posDetect) - 0.25
};
_proximity2 := {
radius > math.vec.dist(pos, scene.my.posDetect2) - 0.26
};
_proximity3 := {
radius > math.vec.dist(pos, app.mousePos)
};
postStep := (e)=>{
a := [0, 0, 0, 0];
b := [0, 0, 0, 0];
c := [0, 0, 0, 0];
_proximity ? {
a = [1, 0, 0, 0]
} : {};
_proximity2 ? {
b = [0, 1, 0, 0]
} : {};
_proximity3 ? {
c = [0, 0, 1, 0]
} : {};
color = [0, 0, 0, 1] + a + b + c
};
Last edited at 2013/12/07 15:52:19 by s_noonan
Thanks guys!

s_noonan - Interesting alternative! It just goes to show that this kind of proximity script can be used to trigger virtually any event that onCollide is typically used to trigger. It doesn't have to be a change in color, but it can trigger a gun, a falling object, an explosion, a moving car....... ANYTHING!
This is a really well thought-out and informative scene!Nice work,Xray
I find this good for drones that follow you when you move into their sensor range.
Thanks VZstrikez08! I appreciate your comments.
hay Xray, i acully need help!

i posted the question on the scean with a name of "ragdolls in ther habbitats (part 1)"
It could work too typing:

color = {
_proximity ? [(color1)] : _proximity2 ? [(color2)] : _proximity3 ? [(color3)] : [(original color)]
}
lololoer,

Good idea. I don't think the code can be more concise than that.
Can you believe that lololoer is only 15 years old? Either he's lying or he's a VERY smart kid! I'm totally amazed by the scripts he comes up with. :)
LOL thnx! :lol:
I really mean what I said. You amaze me! _o_
This is a simple explanation of why lololoer is good with scripts.Imagination and basic understanding of thyme.The better your imagination,the cooler ideas that come to your mind.This also gives you creative ways of solving problems.
again i'm left out of the fun because i have algodoo 2.0.1:'( i'm obselete
bugsbunny - If you are "obsolete" then why don't you download the newest version? :s IT'S FREE!