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 neededneeding to write scripts but I ran into a few snafoosproblems.
So far hereHere is my setup so far:
PaddlePaddle Game Object:
-Box Collider
-RigidBody (Set as Kinematic)
Ball
- Box Collider
- RigidBody (Set as Kinematic)
Ball Game Object:
-Sphere Collider
-RigidBody (not kinematic)
Wall
- Sphere Collider<
- RigidBody (not kinematic)
Wall Game Object:
-Box or Plane Collider
I've
- 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 snafoosproblems:
- CollisionCollision: I was stuck for a while trying to figure out why my Kinematickinematic objects wouldn't collide before stumbling upon the collision matrix. I was wondering what are good approaches to enable Kinematickinematic collisions for my setup;
- ForceForces: I'm confused how ApplyForce is done
ApplyForce
should be used. Even if I pick ForceMode.ImpulseForceMode.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 an "onCollisionEnter"onCollisionEnter
method or change the velocity?
Thanks!