x


Capturing a point

Hi,

What is the best way to test if one object is hovering directly above another for x number of frames?

Note:

  • I also need to send info from the object on top to the one below.

  • there will be multiple points to capture

Thanks in advance for any help!

more ▼

asked Apr 10 '11 at 08:53 AM

Myth gravatar image

Myth
404 21 27 42

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Due to there being many objects trying to capture many objects, Vector3.Distance won't work very efficiently,

Collision is too proving costly and erratic,

Location (array) is too confusing to use on multiple levels

So...

this leaves raycast - which is suddenly not working either.

more ▼

answered Apr 15 '11 at 02:05 AM

Myth gravatar image

Myth
404 21 27 42

(comments are locked)
10|3000 characters needed characters left

Use Vector3.Distance to determine if they are close enough. Or you can attach a sphere to the target object, set it as a trigger and switch off its MeshRenderer. Use that sphere's OnTriggerCollide to detect the condition for capture.

To check if an object is on top of another, I will take the capturing object and use Physics.RayCast to cast a ray down and see if it collides with the point to capture. You can also use the output of RayCast to check if the two objects are close enough.

more ▼

answered Apr 10 '11 at 03:29 PM

Extrakun gravatar image

Extrakun
1.3k 44 56 70

So which way is the BEST?

Apr 13 '11 at 06:51 AM Myth

It depends on which you prefer. If you rather set the range of capture by tweaking the stuff inside the editor, go with the first choice. If you rather do it inside code, go for the second. What is 'best' for me may not be 'best' for someone else.

Apr 13 '11 at 07:06 AM Extrakun
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2482
x1525
x332
x172

asked: Apr 10 '11 at 08:53 AM

Seen: 910 times

Last Updated: Apr 10 '11 at 08:53 AM