Search Unity

trigger does not want to work

Discussion in 'Scripting' started by Trild123787898, Jan 17, 2020.

  1. Trild123787898

    Trild123787898

    Joined:
    Dec 9, 2018
    Posts:
    206
    I don’t want to enter touches with a trigger in the console, I can’t understand why
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class WoodSysteam : MonoBehaviour
    6. {
    7.     public Rigidbody rb;
    8.  
    9.     // Let the rigidbody take control and detect collisions.
    10.     void Start()
    11.     {
    12.         rb = GetComponent<Rigidbody>();
    13.     }
    14.     void OnTriggerEnter(Collider other)
    15.     {
    16.         if (other.tag == "Wood")
    17.         {
    18.             //rb.isKinematic = true;
    19.             //rb.detectCollisions = false;
    20.             Debug.Log("Good");
    21.         }
    22.     }
    23.     void OnTriggerStay(Collider other)
    24.     {
    25.         if (other.tag == "Wood")
    26.         {
    27.             //rb.isKinematic = true;
    28.             //rb.detectCollisions = false;
    29.             Debug.Log("Yse");
    30.         }
    31.     }
    32.     void OnTriggerExit(Collider other)
    33.     {
    34.         if (other.tag == "Wood1")
    35.         {
    36.             //rb.isKinematic = true;
    37.             //rb.detectCollisions = false;
    38.         }
    39.  
    40.  
    41.     }
    42. }
    43.  


    upload_2020-1-17_19-30-7.png



    upload_2020-1-17_19-30-27.png
     
  2. VSMGames

    VSMGames

    Joined:
    Jan 12, 2020
    Posts:
    47
    Make sure the script is attached to a Gameobject which has a child with a collider which has Is Trigger checked.
     
  3. Trild123787898

    Trild123787898

    Joined:
    Dec 9, 2018
    Posts:
    206
    yea
    upload_2020-1-17_21-12-37.png
     
  4. VSMGames

    VSMGames

    Joined:
    Jan 12, 2020
    Posts:
    47
    Also, why do you have the log gameobject parented to the same parent as your fork gameobject? You should separate those.
     
  5. Trild123787898

    Trild123787898

    Joined:
    Dec 9, 2018
    Posts:
    206
    ok