How GetMouseButton dependes of time pressed?

Hi i want do different actions depends of time pressed. i use csharp

GetMouseButton

Use Time.time or Time.deltaTime

if(Time.time < x) A();
else B();

just a very basic example.

ok i do it… if a have problems i say you

the variable x? is input.GetMouseButtonDown or what?

No, it was just an example to what u could do.

float time;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            time += Time.deltaTime;
            if ((int)time > 10) time -= 10;

            switch ((int)time)
            {
                case 0:
                    A();
                    break;
                case 1:
                    B();
                    break;
                case 2:
                    C();
                    break;
                case 3:
                    //etc etc etc
                    break;
                case 4:
                    break;
                case 5:
                    break;
                case 6:
                    break;
                case 7:
                    break;
                case 8:
                    break;
                case 9:
                    break;
                case 10:
                    break;
                default:
                    break;
            }
        }
    }

the % operator is also an option.

mmmm this is my code how can i implement it ?

using System.Collections;

public class PlayerMovement : MonoBehaviour {

    public float fuerzaSalto = 15f;
    private bool corriendo = false;
    public float velocidad = 1f;

    public float distanceTraveled;

    private bool enSuelo = true;
    public Transform comprobadorSuelo;
    private float comprobadorRadio = 0.07f;
    public LayerMask mascaraSuelo;

    private void GameStart () {
       
        distanceTraveled = 0f;
        GUIManager.SetDistance (distanceTraveled);
    }


    void Start () {

        NotificationCenter.DefaultCenter().AddObserver(this, "PersonajeHaMuerto");
   
    }

    void FixedUpdate(){

    if(corriendo){

        rigidbody2D.velocity = new Vector2(velocidad, rigidbody2D.velocity.y);

    }

        enSuelo = Physics2D.OverlapCircle(comprobadorSuelo.position, comprobadorRadio, mascaraSuelo);

    }
   

    void Update () {

        distanceTraveled = transform.localPosition.x;
        GUIManager.SetDistance(distanceTraveled);
        distanceTraveled = Mathf.Round (distanceTraveled);

        if(Input.GetMouseButtonDown(0)){
            if(corriendo){
                if(enSuelo){
                    rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, fuerzaSalto);
                    Debug.Log("1");

                    }

                }
            }else{
                corriendo = true;
                NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeEmpiezaACorrer");
            }
        }
}

You didn’t code this did you? Õ 3 Õ

yes i am spanish i only need with your code implement here:

        if(Input.GetMouseButtonDown(0)){
            if(corriendo){
                if(enSuelo){
                    rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, fuerzaSalto);
                    Debug.Log("1");
                    }
                }
            }else{
                corriendo = true;
                NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeEmpiezaACorrer");
            }

have you got skype?

I don’t know what all of your booleans do, so you should do it instead.
Just copy & paste it at the spot where you want to call a random method. .-.

cand you add me on skype: santimurciano

I do this but the player not jump

if(Input.GetMouseButtonDown(0)){
            if(corriendo){
                if(enSuelo){
                    time += Time.deltaTime;
                    if ((int)time > 10){
                        time -= 10;       
                    }
                    switch ((int)time){
                    case 0:
                        if ((int)time > 1){
                        rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, fuerzaSalto);
                        Debug.Log("1");
                        }
                        break;
                    case 1:
                        if ((int)time > 2){
                        rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, fuerzaSalto+3);
                        Debug.Log("2");
                        }
                        break;
                    case 2:
                        if ((int)time > 3){
                        rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, fuerzaSalto+5);
                        Debug.Log("3");
                            }
                        break;

It’s from 0 to 10, change if statement if u want it to only go to 3.
if you just want to have a random value, why not use Random.Range or Random.value?
whatever o-o

if ((int)time > 2){
time -= 2;

i think that is not my idea that i want… is there other form?