Search Unity

Button mash on a Horror game?

Discussion in 'General Discussion' started by j110113, Feb 10, 2020.

  1. j110113

    j110113

    Joined:
    May 24, 2015
    Posts:
    3
    hey guys, this is my first post on here. I need some help with a button mashing script. so, the idea is that the “thing” catches you, and you button mash to escape its grasp. I’m brand new to coding so.. any tips would be awesome! Thanks guys
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,566
    What kind of help? What is the problem and what did you try?
     
  3. j110113

    j110113

    Joined:
    May 24, 2015
    Posts:
    3
    I’m just not even sure where to start, as of now it hits an event and puts you at a camera. I assume it should also activate a script where you spam the button to prevent the camera from zooming, that’s the idea. I’m very new to the c# and I’ve been looking into a bunch of scripts and tutorials (button mash) on google for say.. arm wrestling, etc, but none seem to explain much.
     
  4. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,566
    IN all honesty, you need to keep reading learning resources till you get it. As in "official unity resources" (from unity.com/learn , unity manual and unity script reference) and not random tutorials online. Start with somethin simpler for a start.

    Rather than dealing with zooming as a first exercise would be to make a GUI element with a normal progress bar, and have the bar fill when the user keeps mashing button, and drop when it is not.

    "Button mashing" is defined as "a button is presed for a short while, then released, thne pressed again". This can be determined within update method by repeatedly calling Input.GetKey. That's the simplest way to do it.