Search Unity

Collisions not detected under mouse control

Discussion in 'Physics' started by Kinkladze11, May 20, 2015.

  1. Kinkladze11

    Kinkladze11

    Joined:
    Feb 25, 2015
    Posts:
    36
    Hey Guys,

    Have posted this in answers aswell so really hoping for a response if poss....

    To keep this simple, I have set up 2 objects to collide ( a sphere and a cube).I have set them both to have rigidbodies and the cube to be kinematic. I have also turned on the sphere's gravity. When I run, the sphere falls onto the solid cube and comes to rest as intended.

    However, when I add a mouse control script (see below) to the sphere and move it around, it just passes right through the cube.

    Can anyone shed any light on why this might be and how to resolve?

    Thanks in advance.........


    void OnMouseDrag()
    {

    Vector3 mousePosition = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, distance);
    Vector3 objpostion = Camera.main.ScreenToWorldPoint (mousePosition);

    transform.position = objpostion;


    }
     
  2. IO-Fox

    IO-Fox

    Joined:
    Jul 14, 2014
    Posts:
    86