x


Range of my tower

How can i sense that an object or prefab(array of prefab) is in range of my Tower. I have a script on tower. Please help, Thanks

more ▼

asked Apr 25 '12 at 02:49 PM

kashifsoftware gravatar image

kashifsoftware
0 1 1

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

1 answer: sort oldest

Vector3.Distance will be your answer here:

var dist = Vector3.Distance(tower.position, transform.position);
if(dist < range)
{
......
}
more ▼

answered Apr 25 '12 at 03:21 PM

Fabkins gravatar image

Fabkins
675 15 20 26

edited your answer to add a link to the doc and correct a typo.

Apr 25 '12 at 03:56 PM Kryptos
(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:

x672

asked: Apr 25 '12 at 02:49 PM

Seen: 331 times

Last Updated: Apr 25 '12 at 03:56 PM