Search Unity

Character Controller Collision Problem

Discussion in 'Scripting' started by freze00100, Jul 25, 2019.

  1. freze00100

    freze00100

    Joined:
    Jul 2, 2019
    Posts:
    9
    Hi well I just started in Unity and in my game Im using a Character Controler to move my player and the problem I have is with the box collider from other objects like trees I have an script to play a sound if the player touches a tree but if I keep moving foward the sound is played many times in 1 frame.

    Is there any way to check if a collition was made dont trigger the function again? .
    I was ussing rigidbody at first with out problem but it was easy for the slopes to use character controller. Should I return to the rigidbody and deal with the slopes?
     
  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    How are you doing the collision? If you only want the sound to play the when the character first collider, use OnCollisionEnter or OnTriggerEnter. Those should only play when the collision first occurs.