Hi all! I have created a game which is quite a simple thing. A ball rolls along the ground and if you collide with something, the ball shoots off to the side and off the edge of the board. But I’m having a major problem, in that when I start the game, the ball automatically bumps off the side of the board. For some reason it is detecting that it has already collided with something, even though there has been no collision because the ball isn’t even moving!
Here’s the area that detects the collision:
void OnCollisionEnter(Collision collisionInfo)
{
if (collisionInfo.collider.name.Contains("Ground"))
{
return;
}
if (collisionInfo.collider.name.Contains("Block"))
{
Instantiate(explosionEffect, transform.position, transform.rotation);
GameObject impactGO = Instantiate(explosionEffect);
Destroy(impactGO, 5f);
Destroy(collisionInfo.gameObject);
AudioSource audio = GetComponent<AudioSource>();
audio.Play();
}
I’m hoping there’s something simple in my coding above that’s causing the error, because if it isn’t in this part then it’s probably somewhere else and I’ll never find it…