Search Unity

Resolved Function on button click not working

Discussion in 'Scripting' started by khrysller, May 16, 2020.

  1. khrysller

    khrysller

    Joined:
    Mar 14, 2019
    Posts:
    125
    I am used to create functions and associate it to a button. But I don`t know why in this case it isn`t working. What I have:

    • A Character with a Character Controller on it
    • Another script with a Jump function
    • The function is triggered in Fire3 and it is working
    • I duplicated this function removing the condition to trigger on Fire3
    Code (CSharp):
    1.     public void Dash()
    2. {
    3.             Debug.Log("Dash");
    4.             _velocity += Vector3.Scale(transform.forward, DashDistance * new Vector3((Mathf.Log(1f / (Time.deltaTime * Drag.x + 1)) / -Time.deltaTime), 0, (Mathf.Log(1f / (Time.deltaTime * Drag.z + 1)) / -Time.deltaTime)));
    5.  
    6.     }
    attached it to a button but it does nothing. Any clues? Thanks

    update

    just for testing i created the following function and it works

    Code (CSharp):
    1.     public void testabc()
    2.     {
    3.         Debug.Log("test");
    4.     }
    Resolved. I had another function blocking it to run. Sorry and Thanks
     
    Last edited: May 16, 2020
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    You don't seem to have an opening "{" on the Dash method...
     
  3. khrysller

    khrysller

    Joined:
    Mar 14, 2019
    Posts:
    125
    Was just a typo copying the script here... but it acctually has
     
  4. khrysller

    khrysller

    Joined:
    Mar 14, 2019
    Posts:
    125
    Solved, thanks