Reso Coder
What makes a perfect game? I think that challenging gameplay certainly plays the main role!
Up until now, we’ve made a pretty functional game, but one core aspect is still missing – opponent. Someone to play against… Making another human-controlled player in our air hockey game would be pretty simple, but that’s not what this particular tutorial is about.
In this tutorial, we are going to make a fully functional, awesome artificial intelligence for our game. This is some exciting stuff, so let’s do it together!
Get all of the code written in this tutorial: http://wp.me/p8jOJP-39
Go to my website for more information, code examples and articles:
● http://resocoder.com
Follow me on social media:
● https://www.facebook.com/resocoder
● https://twitter.com/resocoder
Source
Very good. Thanks for the lesson.
the ball is getting stuck with the ai player at the corner?
My AI does not hit the ball hard enough to cross the middle….it moves sideways and not back and forward….help me please….thank you
Edit: the ai is trying to return to its original starting position if i move it from the scene view. I even copied your code but i couldnt fix
what if we want AI player to hit multiple pucks..???
u need to explain how the code work , and write urself ? thanks just my opinion to get more view
can u help me , the Ai just stay in the AibountaryHolder Right and not moving
Its said NullReferenceException: object reference not set to an instance of an object
AiScript.FixedUpdate() (at Assets/Script/Aiscript.cs:65)
NullReferenceException: Object reference not set to an instance of an object
My code in line 65 is the
rb = MovePosition ( Vector2. Movetowards………
UnassignedReferenceException: The variable Puck of AiScript has not been assigned.
You probably need to assign the Puck variable of the AiScript script in the inspector.
UnityEngine.Rigidbody2D.get_position () (at C:/buildslave/unity/build/artifacts/generated/common/modules/Physics2D/Physics2DBindings.gen.cs:2136)
AiScript.FixedUpdate () (at Assets/Sprite/AiScript.cs:46)
what does it means
This is really starting to annoy me the AI script worked before and now it's not even hitting the puck back at me. Last night I followed this tutorial and it worked great I made a menu when I hit play everything dissapeared. I restarted just now and the AI isn't doing anything
How would I modify the AI Script to hit the puck at a different angle? Right now it is just hitting it straight back and I would like it to try to bounce off the walls and actually try to make it into the goal. Would I modify the target inside the AI?
Transform child out of bounce. I spent an hour looking for any mistakes in the code and still can't find the problem. Could anyone help me pls?
Boundary geting ereas
The AI won't hit the puck. I got the AI to follow the puck wherever it's located, but it won't touch it. Need HELP ASAP!!
hi i have a solution for ball get out but i can't Applied
the solution is
make a boundary for the ball like As we did to player So that the ball can not penetrate
Is this possible?
Please help me as soon possible
Hey there! So my AI isn't working properly for some reason. I copied the code from your webpage but the opponent just follows the puck along the X axis and doesn't actually return it to the bottom part of the field. Any ideas on how to fix this? Pleaaaase help, if I can't fix this I'm gonna fail my class 🙁
Following this tutorial as i'd like to get started with unity. I've followed your tutorial and i have an issue where the AI player doesn't hit back or move on the Y axis at all. I've pasted your code from the link provided just to make sure i didn't make an error and i still have this problem. How could i solve it?
hello can i ask what kind of search algorithm was used in making the ai? thank you!
Hi… I followed your steps but when I want to start play it keeps says, "Should not be capturing when there is a hotcontrol UnityEngine.GUIUtility" Please help me… Thank you…