|
Hi, I seem to have a problem when entering a triggerzone. What i am trying to achieve is, whenever the player enters a certain zone (a well lit zone) What i tried to do is, put a sphere collider on the point light and attach this script:
Also use the collider as a trigger. But this doesn't work. I also tried some tutorials that i could find on google. But they used the same method and didn't work either. Does anyone know a way how to achieve this? Thanks, Darryl
(comments are locked)
|
not sure what the problem is though. See if adding a Debug.Log as above gets called, to rule out issues with the tag.. EDIT : sorry, forgot to mention before You also need to have a rigidbody on one of the objects.. http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html the matrix at the bottom of this link will explain what types of objects can send trigger message just add a rigidbody to the trigger object and set "isKinematic" true EDIT: now I think DO NOT set isKinematic true, this may cause the trigger not to work (unless it moves) as described by my experience here but that's only if the player does NOT have a rigidbody, I believe I tried your script, but it didn't worked either. I can walk through the trigger collider, but the debug log before tag is checked isn't showing up. I thought something like this, was supposed to be simple. Thanks anyway, i am going back to google. See if i can find any tutorials or reference scripts.
Jul 25 '12 at 08:59 PM
darryldonohoe
I just tested the ones on the reference site, they didn't worked either. I also tried to use OnControllerColliderHit on the character controller. But the same problem. I tested the reference ones on the Player itself and on other game objects. It shows no debug log or anything.
Jul 25 '12 at 09:39 PM
darryldonohoe
You also need to have a rigidbody on one of the objects.. http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html the matrix at the bottom of this link will explain what types of objects can send trigger message just add a rigidbody to the trigger object and set "isKinematic" true
Jul 25 '12 at 09:43 PM
Seth Bergman
The only one that is sort of working is the kinematic one. I tried this a few hours ago, but it gave me a message even though i was not in the trigger zone. It also didn't respond when i entered.
Jul 25 '12 at 09:54 PM
darryldonohoe
sounds like the collider was just in the wrong position somehow. that's definitely the way to accomplish this try again, and keep an eye on where the collider is, the only way you entered that function is by hitting a trigger
Jul 25 '12 at 10:11 PM
Seth Bergman
(comments are locked)
|
|
Make sure 'Is Trigger' is checked.
(comments are locked)
|

Is it possible that if i purchase Playmaker, that this would work? Cause i saw a tutorial which explains basically what i need. But if Playmaker uses the same method, there will probably be a high risk that it will not work. But if it uses another method, than it probably will. Because i still don't know what the problem is. I just cant figure it out.
Try changing it to
Debug.Log(other.gameObject);
Debug.Log(gameObject);
you must have something else in the scene tagged as player, or something else with this script attached, or MAYBE your collider is scaled too big, try lowering the size of the collider component on the object
I don't know about Playmaker but this is a solvable issue, some detail is being overlooked is all
am I correct that the issue is still it activates on Start? this can ONLY mean the trigger is in contact with something tagged as Player, maybe the light, or one of its components
see what the above debug tells you
I will take a look maybe you are right, that there are multiple objects tagged as player. Or something else. I'll also check the Debug.Log, what is it tells me. And once i have that checked. I'll post results here.
Thank you!
no prob, hang in there!
by the way, something else I noticed since my prior advice..
setting the trigger to "isKinematic" is a BAD idea, leave isKinematic unchecked, and be sure to turn off gravity, otherwise I've found the trigger won't work unless it MOVES (collision matrix doesn't mention that part)
but only an issue if the player does NOT have a rigidbody
otherwise, I find the collision matrix to be a very useful guide
Well i got it to work finally! I used the standard method. Same setup, different project. I think it had some problems with a script or an object in my old project. Cause right now it works like a charm. And i can finally wrap this feature up. Thanks for helping my out on this one Seth!