Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Adding collider causes weird things

Discussion in 'Physics' started by ShakierHeart53, Jun 3, 2020.

  1. ShakierHeart53


    Dec 23, 2017
    I have an object that I am constantly updating to be at the world position of the mouse, however when I add a collider, and set it to trigger, the object flies at the camera. It starts at the mouse position, then moves closer and closer to the camera along the ray cast. Any help would be appreciated
  2. mineslavan


    May 8, 2020
    i think that's because you hit it with your raycast
    you should make a new layer for your object

     public LayerMask layermask;
    if(Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, range, layermask))