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

Problems with TriggerEnter/Collider

Discussion in 'Scripting' started by nstylesCSS, Aug 19, 2022.

  1. nstylesCSS

    nstylesCSS

    Joined:
    Jan 21, 2022
    Posts:
    5
    //I've been trying to Add more force to OnTriggerEnter2D . I feel like I tried everything. Please help.
    Code (CSharp):
    1.   private void OnTriggerEnter2D(Collider2D other)
    2.     {
    3.         if (other.gameObject.CompareTag("Player"))
    4.         {
    5.             //jump = jumpboost;
    6.             isJumping = false;
    7.             other.gameObject.GetComponent<Rigidbody2D>().AddForce(Vector2.up * jump boost, ForceMode2D.Impulse);
    8.  
    9.         }
    10.         if (other.gameObject.CompareTag("Boost"))
    11.         {
    12.             Destroy(Soap);
    13.         }
    14.     }
     
  2. nstylesCSS

    nstylesCSS

    Joined:
    Jan 21, 2022
    Posts:
    5
    I made jump boost a public float by the way and I did set a number