Hi, it’s a noob question as I’m starting in Unity, I’ve followed the first tutorial the “roll a ball” example project.
Ok, after finish, I’ve tried to add an extra ball that follows the player ball, it worked (chase the player ball) but now I want to detect the collision.
So I added to the second ball a new tag name to controll it in the player script OnTriggerEnter the collision.
I want the ball2 (that chases player ball) to stop on other objects like the player ball.
I’ve added a rigid body too.
If I dont check on ball2 isTrigger, is not detected, when collide, no surprise here.
If I check it it fall the ground.
If I uncheck “use gravity” it does not fall but it oversteps the other objects that player ball can not, collision is detected but this ball is a “ghost” that oversteps objects and walls.
If I check Is Kinematic it does not move and the player collision is detected but the ball oversteps it like a ghost (same that uncheck use gravity but It seems not to move because I got his position from RigidBody rb = GetComponent(); and seems not to exist if I check “Is Kinematic”.
So If I want the ball that chases player1, not to be “a ghost” and detect the event of collision in player1. What do I have to do?
Sure it’s a silly question, I’m a noob but I need the answer…
There are, in total, 6 different kinds of colliders. There’s a write up on them here, I’d suggest you read through it. I know it helped me a lot when I got started with Unity. The grid on the bottom in particular is super-helpfull, as it shows what types of collisions creates what
There’s three main points through. They are: 1 - is your collider a trigger, 2 - does it have a rigidbody and 3 - is the rigidbody kinematic
A trigger collider is an object that things can pass through, and sends the OnTriggerEnter message to scripts when things enter it. You use this for things like checkpoints and hitboxes - things that doesn’t stop movement, but your script needs to know about.
A collider that’s not a trigger stops physics objects from going through it. Walls will definitely be in this category, and depending on your game, your characters might be here. These colliders will send the OnCollisionEnter message to scripts when collisions happens.
A rigidbody is what makes a thing move with physics. The vast majority of rigidbodies will have a collider that’s not a trigger, but there’s some edge cases where triggers are appropriate.
A kinematic rigidbody is not affected by physics forces. They might still affect other physics objects through joints, and you can turn them non-kinematic for things like ragdolls.
In your case, it sounds like the ball should be a non-kinematic rigidbody with trigger turned off, and you should use the oncollisionenter message to detect collisions.