Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by si0ty · Apr 29, 2020 at 02:26 PM · bots

Create Bot who plays my game

Hello Guys, my game is still in development but I'm already excited how this gonna work out. Maybe you guys have some ideas. There is no need to explain my game in depth. It's a 2D RTS type game, where you buy, upgrade and spawn Units with buttons which just head over to the enemy base and fight on there way. The princip is like Clas Royale just in 2D. Later on I want to implement Multiplayer aswell as local playing or campaign vs a bot. How do you implement a bot which plays the game into Unity? I thought about writing different scripts for different difiiculties and just automate in script what a human would do? But this seems so error prone to me. I couldn't really find something on the web but maybe you can kind of "record" button presses in unity? Or what is the best way to do this for this kind of approach? Thanks for any reply. Greets!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Tario · Apr 29, 2020 at 03:24 PM

I would recommend against recording button presses. I've spent many an hour trying to make macros to do repetative computer work for me and it always breaks.

The simplest solution, if your game is just about pressing buttons on the screen, is to trigger the methods your buttons trigger from a seperate, AI script, in a set order over a set amount of time.

Your AI would spawn in units at regular intervals and throw them at your players blindly. A surprising number of single player strategy AIs do this and no one really notices. You'd then playtest each the lists and timings you came up with and test the results to see if it's fun to play against.

That system would be completely blind though: it wouldn't respond to what the player was doing. If you wanted something more complex, I would look into AI patterns like Finite State Machines, Behaviour Trees or Goal Orientated Action Planning. Pick one and build that. (Probably Finite State Machines for your game.)

With Unity Learn free for the next few months, it might be worth seeing if they have tutorials for making a Finite State Machine using the Animator window. If they don't, several youtubers have totally done it.

Any AI will require actions in-game to be seperated from user input though. You don't want to be giving your AI a camera and telling it to put in inputs like a player. You'll need to break up all the possible actions in your game into easy to call methods that the AI can use and create some system that lets the AI interpret the world around them. Raycasts and trigger volumes are quite popular ways of doing this but you can also just keep lists of things in a script somewhere. Look into Object Pooling.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image si0ty · Apr 30, 2020 at 12:53 PM 0
Share

Hey Tario, thanks for you'r reply!

These are some keywords I can work with thanks for these informations.

Have a good one!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

125 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Changing a Raycast for different melee weapons 0 Answers

How can I make a bot follow a predefined path? 1 Answer

Scaling and animation movement 1 Answer

NN setup optimization 1 Answer

How to create a movement system for a bot? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges