- Home /
Pong game collision problems
Hi and frist of all thank you in advance for yout time and sorry for mu english.
Well i just finished my frist game a simple pong clone.
Link to game: http://fdeluna.itch.io/pong-clone
I have two problems,
1º when the ball collide with the up or down wall in a close angle, the ball doesn´t bounce it just get stick to the wall and just stoped.
2º when the balls collide i create particules from a prefab. the problem is that the particules spam in the collision position and in the prefabs position and i dont know to solve this.
Code where i calculate the direcction of the ball and code where i update the direction of the ball
void FixedUpdate () {
transform.position += gameLogic.ballDirecction * gameLogic.speed;
}
void OnCollisionEnter(Collision collision)
{
ContactPoint contact = collision.contacts[0];
Vector3 normal = contact.normal;
gameLogic.ballDirecction = Vector3.Reflect(gameLogic.ballDirecction, normal);
Instantiate(Instantiate(Resources.Load("particle_collision")),contact.point,Quaternion.identity);
}
PS: the code are in differents scrips.
thank you very much.
Answer by Goranks · Mar 19, 2015 at 07:42 AM
Well I don't know about your second question but for first go Edit ->Project Settings->Physics and change Bounce Threshold to 0.1 And if you are using 2D Physics go Physics2D instead of Physics and change Velocity Threshold to 0.1
Hope it will work. Good luck.