Search Unity

Game object not registering raycast when rigidbody has it's position freezed

Discussion in 'Physics' started by Gawron10001, Aug 11, 2020.

  1. Gawron10001

    Gawron10001

    Joined:
    Dec 25, 2018
    Posts:
    4
    So, i have two objects, one is raycasting for the secon one (raycaster and target). The problem i have is when i set any costrains to target, no matter if it is position or rotation the raycaster isn't "finding it". Raycast works fine when there are no constrains.
    upload_2020-8-11_19-2-50.png


    Here is also my code:

    Code (CSharp):
    1.     private void CheckRaycast()
    2.     {
    3.         Ray ray = new Ray (transform.position, transform.forward);
    4.         RaycastHit hit;
    5.  
    6.         if(Physics.Raycast (ray, out hit, maxDistance))
    7.         {
    8.             if(hit.transform.GetComponent<Interactible>())
    9.             {
    10.                 Debug.Log("Hit int");
    11.                 SetIntScript(hit.transform.GetComponent<Interactible>());
    12.             }
    13.             if(hit.transform.GetComponent<Interactible>() != intScript)
    14.             {
    15.                 Debug.Log("Hit but no int");
    16.                 Exit();
    17.             }
    18.         }
    19.         else
    20.         {
    21.             Debug.Log("No hit");
    22.         }
     
  2. clixmods

    clixmods

    Joined:
    Sep 21, 2021
    Posts:
    3
    Help me i have a similar problem :C