Search Unity

Why the ball rolls by itself

Discussion in 'Getting Started' started by NyanGoodWill, Sep 17, 2017.

  1. NyanGoodWill

    NyanGoodWill

    Joined:
    Sep 6, 2017
    Posts:
    10
    I am trying to hit a ball with a golf club.
    Ball's inspector and club head inspector can be seen in the attached images.

    Then ball and club head have sphere colliders and I am expecting they collide each other.
    I properly position the ball just in front of the head in the program

    Vector3 loc = head.GetComponent<Collider>().bounds.center;
    loc.x = loc.x - 0.15f;
    head.transform.position = loc;
    Instantiate(Ball, head.position, head.rotation);

    So at the start of the application in running, the ball is located at in front of the head (please see in the attached image). But after a while, the ball rolls to that direction by itself as in another image.

    I am expecting the two object collide and see in Debug.Log as

    public class PassHeadScript : MonoBehaviour
    {
    void OnCollisionEnter(Collision collision)
    {
    if (collision.gameObject.name == "Ball(Clone)")
    {
    Debug.Log("Collided with ball");​
    }​
    }​
    }

    public class BallScript : MonoBehaviour {

    void OnCollisionEnter(Collision collision){
    if (collision.gameObject.name == "AW52_Head")
    {
    Debug.Log("Collided with club head");​
    }​
    }​


    }
    My queries are
    Why the ball rolls by itself when the application runs?
    Is that the right way to debug as the two objects collide?

    Thanks

    EDIT:

    Now I found out that when I set ball rigidbody's drag and angular drag to 2. It doesn't roll. But it doesn't print Debug Log from both ball and club head during animation of club swing.
     

    Attached Files:

    Last edited: Sep 17, 2017