I've just been using Unity and chose to learn it by making a Pong game which sounded simple enough as a "hello world" type of game. My goal was to try and encompass enough of the built in engine without needing to write scripts but I ran into a few problems.
Here is my setup so far:
Paddle Game Object:
- Box Collider
- RigidBody (Set as Kinematic)
Ball Game Object:
- Sphere Collider<
- RigidBody (not kinematic)
Wall Game Object:
- Box or Plane Collider
I've set my material on my Ball to 'Bouncy' and I get a pretty good bouncing ball (given a starting force).
I've also added the following script to the Paddles:
void OnCollisionEnter(Collision collision)
{
BallRidigBody.AddForce(rigidbody.velocity);
}
Here are some of my problems:
- Collision: I was trying to figure out why my kinematic objects wouldn't collide before stumbling upon the collision matrix. I was wondering what are good approaches to enable kinematic collisions for my setup;
- Forces: I'm confused how
ApplyForce
should be used. Even if I pickForceMode.Impulse
, is that a constant force? I'm a bit stuck on how to get proper bouncing off the walls and paddle. Since I've already applied a starting force, should my wall apply force on anonCollisionEnter
method or change the velocity?