Pickups worth double

During this video a minor bug was introduced. Sometimes when you grab a pickup it will be worth double. I think it has to do with the animation, but I have no idea. Rick has the same bug in both this video, and the next; He just doesn’t notice it. Any ideas how to fix it?

1 Like

First thought is to check a Debug.Log on the method that registers the pickup was received. That’ll at least tell you if the issue is if picking up the collectible is registering twice or if the issue lies elsewhere. Good luck.

1 Like

Alright; I am pretty sure I have the problem cornered now, but I still am not sure how to fix it. I am positive it is being caused by our feet collider. If I jump on the coin then the coin passes two colliders; Thus double points. Any ideas team?
Also thanks Horusofoz; Debug.Log helped!

1 Like

Hi,

I solved the problem this way:

private void OnTriggerEnter2D(Collider2D collision)
{
    if(collision is CapsuleCollider2D)
    {
        AudioSource.PlayClipAtPoint(coinPickupSFX, Camera.main.transform.position);
        FindObjectOfType<GameSession>().IncreaseScore();
        Destroy(gameObject);
    }
    
}

That way the only thing that triggers the pickup is the capsule collider that it’s attached to the player.

Regards!

10 Likes

Man, I think this helped me in more ways than just this pickup problem. Thanks a lot; I will test it out later!

Tested, and this made me realize quite a bit about colliders so Thanks again!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms