Enemy Patrolling Unity Tutorial
HTML-код
- Опубликовано: 20 сен 2024
- Enjoy the video, if you have any questions ask in the comments down below!
Request a tutorial here:
forms.gle/JLBk...
Patreon with fully explained c# scripts:
/ blakeygames
Main Channel: / bblakeyyy
Join the Discord: / discord
Play my games! :
blakey-games.i...
play.google.co...
Watch me Live on twitch: / bblakeyyy
unity tutorial,unity,tutorial,unity 2d tutorial,unity ai tutorial,unity game tutorial,unity enemy tutorial,unity enemy ai tutorial,unity enemy ai,unity 2d,unity 2d shooting,unity tutorial 2d,unity tutorial for beginners,shooting,unity shooting,unity 2d game tutorial,unity 3d tutorial,unity enemy ai 2d,enemy,unity 3d,unity 2d shooting tutorial,unity shooting tutorial,tutorials,unity beginners tutorial,shooting tutorial in unity Audio used in my videos:
♪ Onion (Prod. by Lukrembo)
Link : • (no copyright music) l...
♪ Branch (Prod. by Lukrembo)
Link : • (no copyright music) c...
♪ Biscuit (Prod. by Lukrembo)
Link : • (no copyright music) l...
♪ Bread (Prod. by Lukrembo)
Link : • (no copyright music) j...
Apologies for youtube compressing the darker colours in this video, super annoying that it does that!
Its not so bad i managed to write the code down perfectly.
this is one of the best tut i`ve ever seen ty so much
Awesome tutorial sir. Can you please tell me how to make enemy chase player when in range of the enemy but with this function embedded thank you in advance.
How could I combine this with a chasing mechanic, and once the player is out of reach it'll go back to patrolling?
Yeah i need this answer
For anyone having trouble with this one:
(Did this for 2D, but should work in 3D as well)
In the start method I had to remove ** targetPoint = 0; ** statement otherwise it would reset to 0 after reaching the first targetPoint
In the update method
//instead of setting the game object position to be equal to the targetPoint position set it to, if the game object is within a (very) small distance
if (Vector2.Distance(transform.position, patrolPoints[targetPoint].position) = patrolPoints.Length)
{
targetPoint = 0;
}
}
transform.position = Vector2.MoveTowards(transform.position, patrolPoints[targetPoint].position, speed * Time.deltaTime);
I'm getting an error when I use square brackets in "transform.position = vector3.movetowards(transform.position, patrolpoints[0].position, speed * time.deltatime;" can someone help
Edit: I was using wrong variable nevermind
I'm having trouble with this one. It seems as though once the enemy gets to the position of a waypoint it does not activate the
if(transform.position == patrolPoint[targetPoint].position
I am unsure as to why that might be, and am curious as to your thoughts.
guessing its something to do with the Y's not being the same, think you need to check if the X and Z position of the AI is the same as the waypoints and just ignore the Y, assuming you aren't going up ramps or anything
Can someone help me how to draw a Gizmos Shpere for each point?
Thank you very very much Sir ❣️
How can u make the Patrol bot returning in the same order as it came?
not: 0,1,2 - 0,1,2
but: 0,1,2, - 2,1,0
do you have the solution to this now ?
Very well explained but, struggling with this one with a more update unity to what I was using, watched slowly few time stops after 1st cube wondering if there is a change in new Unity, x y and z same as way points basically duplicated all steps
do you know how to make it so a sphere, in my case a character, look at the target points?
I'm not sure I understand but maybe you can use Transform.LookAT() function ?
lol im having the same issue because I added in an enemy FOV
does it work in 2D?
Should do