Hi,
i want to look if my object i instantiate in realtime is hitting a trigger. But i want to do that withour String comparison. So what i should do in the “OnTriggerEnter” method?
Hi,
i want to look if my object i instantiate in realtime is hitting a trigger. But i want to do that withour String comparison. So what i should do in the “OnTriggerEnter” method?
Doesn’t the cost of a string comparison pale to the overhead of receiving a callback in mono? Correct me if I’m wrong.
String comparisons are very quick in runtimes like Mono that use interned strings. If this is your reason for avoiding strings, I wouldn’t worry about it.
but for the iPhone String Comparison needs a lot of memory
Really? I’d be interested to find out why that is the case. Do you know why or is there any chance you could point me to where it is documented?
Anyway, you can also get the transform from the collider object that is passed to OnTriggerEnter. If you have a reference to that transform (or the GameObject, etc) stored in your script, you can compare it for equality with the colliding transform:-
Transform stored;
...
void OnTriggerEnter(Collider coll) {
if (coll.transform == stored) {
...
}
}