Search Unity

Objects visual gets mixed when collided

Discussion in 'Physics' started by yerahmat, Jul 12, 2019.

  1. yerahmat

    yerahmat

    Joined:
    May 18, 2019
    Posts:
    3
    I am making project in unity 3d -2019.1.9f1 which includes a object(eg. cube) hitting group of objects. When the object is colliding with group of objects, the mesh is getting mixed means the UI of both getting merged.

    here is the collision function

    void OnCollisionEnter(UnityEngine.Collision collisionInfo)
    {
    if (collisionInfo.gameObject.tag == "EnemyShape")
    {
    Debug.Log("Collided with enemy shape");
    //movement.enabled = false;
    GameManager.gm.showOptions();

    if (GameManager.gm.Sound)
    {
    audioSource.PlayOneShot(OtherShapeCollision);
    }

    if (GameManager.gm.Vibration)
    {
    Handheld.Vibrate();
    }

    if (collisionParticle.isStopped) {
    Debug.Log("Collision particle is stopped, playing it");
    trailParticle.Stop();
    collisionParticle.Play();
    }

    movement.ballSpeed = 0;
    movement.camSpeed = 0;
    movement.bonusBallSpeed = 0;
    }
    else if (collisionInfo.gameObject.tag == "FriendShape")
    {

    #if UNITY_EDITOR
    Debug.Log("Collided with friend shape");
    #endif

    //movement.enabled = false;
    if (GameManager.gm.Sound)
    {
    audioSource.PlayOneShot(SameShapeCollision);
    }
    }
    }

    here is the object movement function-

    void forwardMovemnent()
    {
    if (currentObjectDistance < maxObjectDistance && currentObjectDistance > minObjectDistance)
    {

    rb.velocity = Vector3.forward * ObjectSpeed;
    }
    else
    {
    rb.velocity = Vector3.forward * camSpeed;
    }
    }

    Any solution how can i fix this ?
     

    Attached Files:

    • 1.png
      1.png
      File size:
      10.1 KB
      Views:
      442
    • 2.png
      2.png
      File size:
      17.5 KB
      Views:
      443
    • 3.png
      3.png
      File size:
      17.5 KB
      Views:
      432
  2. Wezai

    Wezai

    Joined:
    Dec 30, 2016
    Posts:
    74
    Try changing your cube's rigidbody collision detection and etc in the component editor. I think making it an interpolation with a continuous detection works.
     
  3. yerahmat

    yerahmat

    Joined:
    May 18, 2019
    Posts:
    3
    tried it, didnt help at all