|
I have four objects: Player (Box Collider with trigger disabled), Bullet (same as player), a ball (Sphere collider with trigger on), and a goal (Mesh Collider with trigger disabled). I need the player to be able to trigger a ball pickup, and the ball to collide with the goal (say the player shoots the ball from an odd angle, and misses the hole), and I need the bullets to collide with the player and cause them to spin out. I can get the bullets, players, and balls to interact properly. But, I can't seem to find the right combination to make the ball collide with the goal, and bounce off. The strange thing is, I had all four of these objects working perfectly as they should, but somewhere along the path, I broke these things somehow. If I turn the player into a trigger, then the ball into a non-trigger, then bullets go through the player without collision, yet the ball will bounce off the goals. Any ideas would be appreciated.
(comments are locked)
|
|
I did not resolve this by messing with the triggers, however I opted to add a second Collider to the ball. The first Collider has the trigger turned off, and collides only with the goals, thanks to the physics matrix in the preferences. The second Collider, with a trigger, is a child GameObject of the ball, and triggers when players touch it.
(comments are locked)
|
|
Since the ball is a trigger, you should be able to add the code to the balls OnTriggerEnter function. if(collider.tag == "goal") //etc... If you wanted actual physics, you could turn trigger off during a shot, that should allow normal collision detection something like: EDIT: another option is to add an empty child object to the ball, and make THAT the trigger Finally, for the full picture, go to this link, and scroll down to the bottom: http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html the collision matrix there will answer your exact questions.. Thanks for the input. I did think of this, however the ball also needs to be passed from player to player, and with the trigger turned off, the ball would bounce off of players.
Jul 21 '12 at 06:40 AM
XaeroDegreaz
if you want it to have physics, you don't really need the trigger.. just use OnCollisionEnter for everything.. if that's not desired, see the first suggestion above edit: or the third..
Jul 21 '12 at 06:42 AM
Seth Bergman
(comments are locked)
|
