Welcome,
Guest
. Please
login
or
register
.
January 24, 2025, 05:36:47 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Can use a bit of help on casting a ray.
« previous
next »
Print
Pages: [
1
]
Author
Topic: Can use a bit of help on casting a ray. (Read 1953 times)
JSorrentino
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 30
Can use a bit of help on casting a ray.
«
on:
June 05, 2014, 11:18:40 PM »
Collider2D
[
]
results
=
new
Collider2D
[
10
]
;
void
RaycastForHits
(
)
{
int
hits
=
Physics2D
.
OverlapCircleNonAlloc
(
col
.
center
, 0
.
5f, results
)
;
Debug
.
Log
(
hits
+
" hits"
)
;
}
When a 2d collider is touched (OnPress), I am trying to cast a ray from the center of that collider (2d circle), to see if any other objects (of the same type that triggerd the raycast) overlap. I'm sure I'm doing something wrong, and can use a hand. I'm getting erratic results.
Also, I need to set the radius of the ray cast to match the size of the collider (same one used above as col.center).
Any help appreciated.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Can use a bit of help on casting a ray.
«
Reply #1 on:
June 06, 2014, 02:39:58 AM »
Non-alloc API is brand-new, and has bugs in it, so I can't comment on this at all. Try using a simple Physics2D.OverlapPointAll instead like NGUI does in UICamera's Raycast function.
Logged
JSorrentino
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 30
Re: Can use a bit of help on casting a ray.
«
Reply #2 on:
June 06, 2014, 09:57:41 AM »
Disregard, sleep helps, apparently licking windows was my thing of the day.
Sorry to waste your time, Aren.
«
Last Edit: June 06, 2014, 10:41:15 AM by JSorrentino
»
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Can use a bit of help on casting a ray.