Forum rules - please read before posting.

Checking for Input within a Custom Script

AntAnt
edited April 2016 in Technical Q&A
Hey guys, on a hotspot I'm calling a custom script.  Within this script I have a coroutine which executes the following code:


        while (KickStarter.playerInput.GetMouseState () == MouseState.HeldDown ) {

            ACDebug.Log (" Mouse button Held down");

            yield return null;

        }




              // Following code would continue when button is not held down
             // rest of code

I assumed that this would execute the contents of the while loop while it's true (i.e. the mouse button is held down) however it doesnt seem to work.

Is it possible to detect for input (specifically here a mouse button being released) in a custom script? Or does all input have to use the Active Input system?

Thanks

Comments

  • What's the context of this code?  In what function is it written?  You're far better of writing this in an Update() function rather than using co-routines.

    There's no requirement for you to use AC's Active Input system.  You don't even have to use AC's GetMouseState function - detecting the state of Input.GetMouseButtonUp is just as valid.
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.