Forum rules - please read before posting.

Replace mouse click by interactionA button

Hello everybody.

I found a tutorial on youtube to make a puzzle with pipes.
All interactions are done using the mouse and in order to integrate it into my project I would like to replace the action with the left click by pressing the interaction button.

here is the script used for the action on the left click of the mouse:

private void OnMouseDown()
    {
        transform.Rotate(new Vector3(0, 0, 90));

        if (PossibleRots > 1)
        {
            if (transform.eulerAngles.z == correctRotation[0] || transform.eulerAngles.z == correctRotation[1] && isPlaced == false)
            {
                isPlaced = true;
                gameManager.correctMove();
            }
            else if (isPlaced == true)
            {
                isPlaced = false;
                gameManager.wrongMove();
            }
        }
        else
        {
            if (transform.eulerAngles.z == correctRotation[0] && isPlaced == false)
            {
                isPlaced = true;
                gameManager.correctMove();
            }
            else if (isPlaced == true)
            {
                isPlaced = false;
                gameManager.wrongMove();
            }
        }
    }
}

By what I would like to replace the OnMouseDown()?

Thx

Comments

  • some precisions. Currently, I can change using the left mouse click (on a piece of pipe that has a 2d Box Colider) the position of a pipe (0,90,180 or 270 deg). I would like to change the position of the pipe 'by clicking on it using the button associated with InteractionA.
  • OnMouseDown is a special function that detects mouse input. There isn't an equivalent for generic input detection. For that, you'd need to detect your input in an update loop:

    void Update ()
    {
        if (Input.GetButtonDown ("Interaction"))
        {
            // Do something
        }
    }
    

    However, this isn't involving AC - only the shared name of the "InteractionA" input you want to read. This is a topic for the general Unity forums.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.