Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

C# Autoclicker protection.

Discussion in 'Scripting' started by traderain, Jul 22, 2015.

  1. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    Hi, I am creating an idle game in c# but i need a way to protect myself from autoclickers. How can i do that?
    This is how I handle attack:
    Code (CSharp):
    1. if(Input.GetMouseButtonUp(0))
    2.             {
    3.                 StartCoroutine(Player_Attack());
    4.                
    5.             }
     
  2. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    There is no actual way to really detect an auto clicker. Assumably, you could time stamp when they click down and when they click up, and if it's the same time consistently say for 5 clicks, you could create a pop up message that says, "are you still there?" but ideally, for something like this, you can't really control it.

    You could set a timer for how often you can click up. Or some games add random events to prevent this. Ex: Random event for more exp and they have to click something. It will throw off the auto clicker because it most likely won't be clicking in the right spot to click the extra exp.
     
  3. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    Thanks i will try that. If anyone knows an asset for this or any other idea (eg. video) I am open for suggestions.
     
  4. Stepepper

    Stepepper

    Joined:
    Aug 1, 2013
    Posts:
    18
    The idea SubZero has is one of the only ways of approaching it. But that doesn't stop auto clickers from random intervals.
     
    SubZeroGaming likes this.
  5. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    You should give up on this IMO- it's a road to folly. As Stepepper says, you can easily create a slight interval difference when you're making an auto-clicker (you can do it in one line of code, even). Anything you make that will be versatile enough to stop auto-clickers will also stop 10x more actual people actually trying to play your game legitimately, which will do far more damage than good (the same as DRM, which only serves to slow down people who actually bought the software, not the people who stole it). Not only that, but the auto-click script doesn't interact directly with your game or its memory- it interacts with the IO devices and the OS, which then interact with your game (by proxy). There's just no way to stop that- people make their own scripts in AutoHotKey and such most of the time, so you can't even do memory searches for currently-running popular programs. It's just impossible IMHO. Sorry.
     
    traderain and SubZeroGaming like this.
  6. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008

    This leads to a great point. Focus on those who will play your game the intended way. If you try to stop cheaters and hackers, you'll just become a target.
     
  7. Stepepper

    Stepepper

    Joined:
    Aug 1, 2013
    Posts:
    18
    It's already a lost cause fighting cheaters (and pirates). It won't work, there are many AAA games out there that still have cheaters. Look at Counter Strike Global Offensive for example, they did a great job with preventing cheaters but they're still there, and hard to battle. Just make your game the way you want it, most people won't even try to cheat.
     
  8. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    Thank you for the replies.
     
  9. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    There is more then one way to skin a cat. If auto clickers are a problem, eliminate clicking altogether.

    This idle game cannot be defeated by auto clickers, check it out.
     
  10. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    203
    Sorry for reviving an old thread.
    But i was thinking of moving the click button randomly in a predefined area. Do you think that will be such a bother to normal players that they would stop playing?

    Another is that i could limit the number of clicks/sec for normal users, and put an option to remove this limit for people who want to use autoclickers but their highscores would not be saved.
     
    Last edited: Dec 1, 2016
  11. eisenpony

    eisenpony

    Joined:
    May 8, 2015
    Posts:
    971
    Change your mindset. Allow players to play the way they see fit. If that means cheating, so be it. Many great games actually include cheat codes to make this easier to do in a complex game. Your goal should be to make things fun for as many people as possible, not restrict the fun to a select group of "click lovers".

    If part of your game requires a balanced community (item rarity, money, high scores etc..), prepare a business process to identify, mitigate and eliminate exploits as they are discovered by your player base. If you want to reduce cheating, create and enforce a penal code such as account locking, character resets or IP banning. This has to be an ongoing, human process as there is no technical silver bullet to prevent cheating.
     
    Kiwasi likes this.
  12. Kalladystine

    Kalladystine

    Joined:
    Jan 12, 2015
    Posts:
    227
    It would definitely be a nuisance at least, while adding maybe a couple of hours (at best, depending on tools used and skill) to the time one would need to bot it. Once you find the boundaries (which could also be done via scripting), it's just a matter of f.e. sampling pixels, or just sending more clicks spread around the area, or a ton of other techniques.
    Just remember that for a botter it's a one-time cost to overcome (and if it's challenging that's actually a plus for many), while normal players will have to deal with it the whole time.

    While I agree with the notion that actual punishment should be reviewed by a human in most cases, at least flagging can (and if one wants to enforce it - should) be automated.

    From personal opinion I'd even go as far as to say that the best cheating prevention is making it too high risk and/or not worth it. All strictly technical barriers will sooner or later be broken, while adding to development cost.

    This is quite a nice approach in my opinion. It shows respect to the player - sure, there will be those that try to autoclick while saying they don't, but if you show that you respect the players, generally they will respect the game in return.
    One thing I'd change is instead of not saving the highscores at all, have 2 separate ones. Then the autoclickers can interact with each other too, and if you flag and review someone as "cheating" in the human-only leaderboard, just force their score to be in the free-for-all one.
     
    image28 likes this.
  13. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    203
    Thank you guys, not using the moving clicker, adding two separate leaderboards.
     
  14. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    I like the idea of separate high score boards, to some coders/gamers playing the game isn't as much fun as programming a bot to play the game.
     
  15. boxhallowed

    boxhallowed

    Joined:
    Mar 31, 2015
    Posts:
    513
    There's also the possibility you could shadow ban those people who are cheating. The basic idea goes like this:

    - Make cheating LOOK like it's super easy. You can achieve this by giving your button a consistent space, no fast press detection (that the player can see), the same network traffic, ect.
    - Actually then have cheat protection, something layered like "Are they pressing faster than the fastest press-rate?", "Is their timing too consistent?" ect.
    - If they meet the criteria, pass along the highscore info to the board. On THEIR device and account, show them on top of the leader board, but to everyone else, don't show them at all.

    This won't stop it, but you get the idea.
     
    Glitch-TL likes this.
  16. leo_u

    leo_u

    Joined:
    Apr 19, 2020
    Posts:
    2
    Auto clickers always click on the same spot, over the same time-frequency. So you just implement something to log the time between clicks and the XY position of the clicks. If a coordinate gets repeated more than a certain amount, it's an auto click.

    Also, people that use this, leave it clicking for hours, so you don't need to worries about someone that just lunch your application.

    Another smart solution is to spawn for one second a super small button 1x1 exactly over the coordinate that had been clicked.