# How to make Ai use ouMouseDown() and onMouseUp() function in unity?

I want to make an ai for my game.

Currently my game controller uses onmousedown and onmouseup functions and some other factors?

My game is for two players on same screen but you don't always have someone to play game with so I wanna design Ai for that. How can I go about to design Ai for something like that?

• Make a function containing your events and call them with onMouse for the player. You can then just call the function when needed in the AI script Sep 13 at 16:19

If yes, then one way you can solve this is by not putting your game logic into onMouseDown and similar functions. If you keep the general logics separate, those input functions will just invoke the needed logics code (or maybe queue some actions, if you're going for a more robust approach). By itself it's not very different, you just have your code in another function now and have to call it. But on the other hand, your AI now does not need to create "input events" and can perform in-game actions directly (or, again, queue them).