Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / magnetic effect.

Author
Message
HomerS
16
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 16th Nov 2013 20:29
Hi all,

i want to make a board.

on the board is an hole.

When i hover a box over the hole, it should be automatic placed in the hole.

Like a piece of a puzle that fits automaticalley when you come near the place.

Am I right to use a hidden hit box in that area, or is there an alternative way?

Greetings,

Jeroen

Toedeledoki
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 17th Nov 2013 00:35
Is this 2D or 3D?


Formerly OBese87.
HomerS
16
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 17th Nov 2013 13:41 Edited at: 17th Nov 2013 14:46
Sorry,
i want to make it 3d, but is it different for 2d?

try to make a cicuit board voor our pupils on school. so the elements have to "click" on it, when they are almost on place, so that the board looks good, and de elements are not hovering (and not making contact).

Greetings.

Toedeledoki
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 17th Nov 2013 21:17
You could use a simple distance check:


Where MaxDistance# is the SQUARE of the maximum range for "snapping" to the desired location (so if you want it to snap when the board gets within 5 units of the hole, your MaxDistance# would be 5*5=25).

If the program is 2.5D (ie, the user has no control over the Z axis position of the board), you don't need to check the z axis positions, only X and Y.

If you have more complex shapes, you could load one object as the "hole" object, then just check for object collision between the hole and board objects.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose

Login to post a reply

Server time is: 2024-03-29 06:22:43
Your offset time is: 2024-03-29 06:22:43