- Home /
Design choice for collision
Hello.
I am making a really simple 3D ping-pong alike game.
I have 2 players/models who look human-alike. They have arms with multiple colliders. They are placed on left and right side of the screen.
I also have a football/soccer ball. The ball has a sphere collider with bouncy material, bounciness set to 1, and a rigidbody using gravity. it pretty much bounces around in 2 dimensions for now.
The players arms are moved by the actual players.
What I am now thinking is where do I detect the collision? Attach a script to ball and act on OnTriggerEnter()
or do I add CharacterControllers
to the body parts and change ball's direction,angles, rotation with OnControllerColliderHit()
?
Ps. how should I go about detecting how the ball collided with arms? (CollisionFlags?). Also how (after calculation) do I "tell" the ball to go in a direction the player "indicated"?
Any advices and critiques much welcome.
Answer by Salzmann · Apr 11, 2014 at 09:38 AM
The Gameobjects you want to have a collision between both have to have a type of Collider on them and one of them has to have a non-kinematic rigidbody. Then, once one Collider hits the other, OnCollisionEnter is called on both Gameobjects. If there is a script there on any of those two Gameobjects that uses this method it will be called.
Your answer
Follow this Question
Related Questions
Collision problems with level design 1 Answer
Internal collisions 1 Answer
Using a collider to define the boundary of a level? 3 Answers
3D Building Object collider not working 0 Answers