YouTube2Text

Hello Neighbor UE4 AI Tutorial #1 | Chase and Catch (REMAKE) — Transcript

by Owen Campos · 5,848 words · 1,033 segments · language en · Watch on YouTube

Full transcript

  1. 0:00wo oh I'm making another tutorial wow
  2. 0:02wow that's so crazy let's just get on to
  3. 0:04it firstly we're just going to make the
  4. 0:06ground work or the framework it's called
  5. 0:09for the AI so in the soed folder in the
  6. 0:14new version of the template you'll find
  7. 0:16this blueprints folder with just the uh
  8. 0:19blend space and the animation blueprint
  9. 0:21for the neighbor we're going to right
  10. 0:24click here cck blueprint class and click
  11. 0:27character we'll call this BP neighbor
  12. 0:31then we'll open
  13. 0:33this and we'll set the mesh to the
  14. 0:38neighbor low poly
  15. 0:40mesh set it to use the ABP neighbor
  16. 0:44animation blueprint we'll move this down
  17. 0:48so it's there then rotate it so that
  18. 0:51he's facing the correct direction there
  19. 0:54we go now we have the basic the very
  20. 0:57very Bare Bones basic uh
  21. 1:01framework and stuff
  22. 1:03for now now we have the basic animations
  23. 1:06for the
  24. 1:07AI now now we're going to create go back
  25. 1:12now we're going to go back now we're
  26. 1:15going to go back into the blueprints
  27. 1:17folder right click do go to Blueprints
  28. 1:21and click enumeration we call this e
  29. 1:24neighbor
  30. 1:27State and of course as you can guess gu
  31. 1:30will'll have four states here one called
  32. 1:36Idol one called
  33. 1:40hunt one called
  34. 1:42offline and one called
  35. 1:47attack idle hunt offline attack these
  36. 1:49are the four states that we'll be
  37. 1:51working within the entirety of these uh
  38. 1:54these updated AI
  39. 1:57tutorials and back in the blueprint for
  40. 2:00the neighbor we're going to create a
  41. 2:01variable called current
  42. 2:04state and we'll make this a Type e I
  43. 2:08can't spell e neighbor State there we go
  44. 2:11all that and we're also going to create
  45. 2:14a Boolean called cany
  46. 2:18[Music]
  47. 2:21player and that's pretty much all the we
  48. 2:24have to do in terms of like like
  49. 2:27everything non uh like print and nodes
  50. 2:30and all that for the uh for the for the
  51. 2:33BP neighbor now we're going to go back
  52. 2:35into the blueprints folder make a new
  53. 2:37folder we call this
  54. 2:40behavior and here is where we're going
  55. 2:43to keep all of our stuff related to the
  56. 2:45ai's
  57. 2:46behavior and so we're going to go to
  58. 2:49artificial intelligence click Behavior
  59. 2:51tree we'll call
  60. 2:54this uh
  61. 2:57neighbor Idol BT
  62. 3:02or actually we'll call this BT neighbor
  63. 3:07Idol duplicate
  64. 3:09this call this BT neighbor
  65. 3:14hunt call this BT neighbor
  66. 3:17offline and and finally BT neighbor
  67. 3:24attack and finally we're going to make
  68. 3:27one last thing a Blackboard we call this
  69. 3:32BB
  70. 3:34neighbor let's save all of this and now
  71. 3:38we have the different Behavior trees in
  72. 3:39the Blackboard for in for the AI States
  73. 3:45and basically what we're what we're
  74. 3:47going to be making the AI do is we're
  75. 3:48going to make it switch between these
  76. 3:51four Behavior trees whenever it wants to
  77. 3:54switch States this will basically
  78. 3:56prevent any behavior from overlapping
  79. 3:59one another such as uh idle t such as
  80. 4:03Idle tasks overlapping with uh hunt mode
  81. 4:06tasks and he'll try to do idle tasks in
  82. 4:10the middle of hunt mode and
  83. 4:12it's yeah that that's basically this is
  84. 4:15basically to prevent that this is
  85. 4:17basically to prevent
  86. 4:19that so now that we have this we're
  87. 4:23going to go back into BP neighbor I'm
  88. 4:24going to create a new function called
  89. 4:26set state
  90. 4:28[Music]
  91. 4:30and firstly in this function we're going
  92. 4:31to go do a branch here and we're going
  93. 4:34to check if the current
  94. 4:37state uh oh actually I forgot to do one
  95. 4:39thing got to make an input called New
  96. 4:43State and make this type e neor State
  97. 4:48there we go and we're and before we do
  98. 4:52anything within this function we want to
  99. 4:55check if the new state is not equal to
  100. 5:00the uh you know what actually let's
  101. 5:02let's just do a regular not you will
  102. 5:04know that that actually is easier so we
  103. 5:08first want to check if the new state is
  104. 5:10not equal to the current state we want
  105. 5:13it to do everything
  106. 5:16here only if it is not currently in the
  107. 5:20state that it wants to switch to if it
  108. 5:24cuz obviously uh in attack
  109. 5:27mode uh we don't want it to constantly
  110. 5:30switch to attack mode uh Behavior tree
  111. 5:35because it's basically going to
  112. 5:36re-trigger out all of it over and over
  113. 5:38and over and over and over again and
  114. 5:39it'll be very buggy and whatever not
  115. 5:43good so this is basically all we have to
  116. 5:45do to prevent
  117. 5:47that so now we're going to get the AI
  118. 5:53controller the controlled actor being
  119. 5:55self of
  120. 5:57course and we're going to do run
  121. 6:00Behavior
  122. 6:03tree off of the true and off of the BT
  123. 6:06asset we're going to do still a select
  124. 6:09node and connect the index to here and
  125. 6:12it'll do this lovely little thing where
  126. 6:13it'll automatically have each option for
  127. 6:18all of the
  128. 6:19states so for idle of course we're going
  129. 6:23to use BT neighbor Idol or hunt we're
  130. 6:25going to use BT neighbor hunt and so on
  131. 6:30[Music]
  132. 6:33now if you want
  133. 6:36to you could also do a select not oh no
  134. 6:42not select uh switch on you never State
  135. 6:45there it is you could also do this and
  136. 6:48you could also have different uh
  137. 6:50different uh like uh things trigger
  138. 6:54depending on what state it is being set
  139. 6:57to uh actually actually let's do that do
  140. 7:00that now let's do that now uh cuz we do
  141. 7:03want the uh Max walk speed to be that
  142. 7:10depending on what state it's in actually
  143. 7:13let's do it let's just use another
  144. 7:15select node for this just to make it
  145. 7:22easier so let's see what is the current
  146. 7:26Max block speed 600 that's way too fast
  147. 7:29for idle let's do
  148. 7:31150 for hunt let's do
  149. 7:35300
  150. 7:37offline 200 sure uh attack will be
  151. 7:44600 so idle of course is wherever you
  152. 7:46want to we just walk and I believe in
  153. 7:50the blend
  154. 7:53space uh it
  155. 7:56is okay the walks the walk is at uh 100
  156. 8:01okay so let's actually 100 instead of
  157. 8:04[Music]
  158. 8:07150
  159. 8:09cool now that we have all of
  160. 8:12that let's actually get him to chase the
  161. 8:16player because currently if we drop him
  162. 8:20here
  163. 8:22uh he just doesn't do anything he
  164. 8:25literally doesn't do
  165. 8:27anything hello
  166. 8:30you look very handsome today Mr
  167. 8:34Peterson yeah he does literally nothing
  168. 8:37right now so we got to fix that let's
  169. 8:41add an AI perception component and we'll
  170. 8:44just call this site
  171. 8:48component We'll add a new sensus config
  172. 8:51call this AI not call this uh set it to
  173. 8:54the AI scyon fig click the drop down
  174. 8:56click the drop down again and then the
  175. 9:00peripheral vision is is uh basically the
  176. 9:04the angle of the cone of like the cone
  177. 9:07of the AI site uh if I actually go into
  178. 9:10here and press the uh apostrophe and
  179. 9:14then press four on the numpad as you can
  180. 9:16see there's this little green these
  181. 9:19little green lines
  182. 9:22here uh this is the ai's uh peripheral
  183. 9:25vision So currently it's set to 90 so
  184. 9:28it's just going to be
  185. 9:29basically a
  186. 9:31180° uh sight lines for him which
  187. 9:35obviously we don't
  188. 9:37want uh let's I usually set it to
  189. 9:4185 but we could do 80 let's see how that
  190. 9:45looks let's see what that is
  191. 9:48okay uh 85 is a little 80 is a little
  192. 9:52too small let's do
  193. 9:5485
  194. 9:56cool however
  195. 9:59as you can see if we go into his uh line
  196. 10:01of sight uh nothing really happens and
  197. 10:05trust me there is something that's
  198. 10:07supposed to be like shown like a de
  199. 10:09little debug visual such as the little
  200. 10:12green lines here uh to fix that we have
  201. 10:15to go into detection by affiliation and
  202. 10:19just check all of these that way
  203. 10:21anything that has an uh AI perception
  204. 10:25stimuli Source component uh registered
  205. 10:29to it will um he will be able to see so
  206. 10:35now now if we go in his line of sight
  207. 10:40here as you can see there's this little
  208. 10:42sphere that follows us here that means
  209. 10:45that he is able to see us
  210. 10:48awesome
  211. 10:50so now let's go back into the blueprint
  212. 10:53and go down to here on target perception
  213. 10:56updated click that little plus sign
  214. 10:59there
  215. 11:00and for the actor we're going to do cast
  216. 11:02to BP
  217. 11:06human do break this is actually going to
  218. 11:09be very very
  219. 11:11simple literally all you need to do just
  220. 11:14set cany player to successfully
  221. 11:17sensed that's all this needs to do right
  222. 11:20now we just need it to to to update cany
  223. 11:25player so that we can use that for a
  224. 11:27whole bunch of different purposes but
  225. 11:29for right now we're just going to use it
  226. 11:30for
  227. 11:31chasing now for switching the state
  228. 11:35there are a couple ways you could do it
  229. 11:39uh and I mean in particularly uh having
  230. 11:43it constantly checking what you can do
  231. 11:46is you can use event tick
  232. 11:48however given depending on how complex
  233. 11:51your AI is you would instead want to do
  234. 11:55a set timer by event thing and set it
  235. 11:59to1 seconds and looping and make a
  236. 12:04custom event here and basically this
  237. 12:08would be a pseudo event tick where
  238. 12:10instead of this working off of uh the
  239. 12:12frame rate uh this would just work on a
  240. 12:15completely separate timer rather than
  241. 12:18that completely desinc from the uh from
  242. 12:21the frame rate uh I usually do this
  243. 12:24because I usually like to make complex
  244. 12:26more complex AI so that's just what
  245. 12:28we're going to do
  246. 12:29uh just keep in mind that you can use
  247. 12:32event Tech if you want uh just be
  248. 12:36mindful of the performance issues that
  249. 12:39that could introduce if you put a lot of
  250. 12:42stuff on aent tick but
  251. 12:45anyways off of neighbor tick we're going
  252. 12:48to do a sequence node because we're
  253. 12:51going to do a couple things at once on
  254. 12:54the neighbor tick Uh custom event here
  255. 12:58and we're going to to a branch
  256. 13:01[Music]
  257. 13:02here can see
  258. 13:05player it's going to be very simple if
  259. 13:07you can see the player set the state to
  260. 13:12attack right
  261. 13:14[Music]
  262. 13:16here
  263. 13:18and we're actually going to do one last
  264. 13:20thing in set
  265. 13:22State we're going to do a switch on E
  266. 13:27neighbor State here
  267. 13:31a new state not neighbor
  268. 13:33State uh we're going to add double click
  269. 13:36on the string here for a reroute node to
  270. 13:40make it a bit more
  271. 13:42organized and off of attack we're going
  272. 13:46to actually before we do anything I
  273. 13:49forgot one thing add an
  274. 13:53audio
  275. 13:55and search for attack I believe it is
  276. 13:58attack
  277. 14:00Q yep it's attack q and it's looping yep
  278. 14:04it's looping cool so this will be the
  279. 14:07chase music let's just call this Chase
  280. 14:12music and we want to turn off
  281. 14:14autoactivate because what will happen is
  282. 14:18if we press
  283. 14:19play it'll just play at the very start
  284. 14:22and we don't want that so just turning
  285. 14:25off auto activate will prevent that from
  286. 14:27happening
  287. 14:29cool so now back in set State we're
  288. 14:32going to off of the attack on the switch
  289. 14:35here we're going to add a branch Dragon
  290. 14:39the chase music I'm going to check is
  291. 14:43[Music]
  292. 14:46playing and if it isn't already playing
  293. 14:50we're going to press
  294. 14:51[Music]
  295. 14:57play and and again the reason why we
  296. 15:00want to check this instead of just
  297. 15:02having it go uh straight to play here is
  298. 15:06because we are going to be triggering
  299. 15:10set State on event tick or or our
  300. 15:13version of event tick and of course we
  301. 15:17don't want it just repeating over and
  302. 15:19over and over and over and over
  303. 15:21again uh so we're we're just going to
  304. 15:24add a fail safe here and just and just
  305. 15:27make it check if it is already playing
  306. 15:30just to make sure that uh just to make
  307. 15:34sure
  308. 15:35that uh that it's
  309. 15:37actually you know playing at the right
  310. 15:40time and playing correctly
  311. 15:43so
  312. 15:45now if we press play
  313. 15:49here everything is fine there's no music
  314. 15:51playing but as soon as we get into his
  315. 15:53line of
  316. 15:57sight cool
  317. 16:01so
  318. 16:04finally we're going to go into the
  319. 16:08neighbor attack Behavior
  320. 16:11tree create a
  321. 16:15selector and we're going to create a new
  322. 16:17task here by clicking new task and in
  323. 16:20here it's going to create a new BT task
  324. 16:23blue Bas new we're going to call this BT
  325. 16:26task attack
  326. 16:28[Music]
  327. 16:30and let's actually put this in a in a
  328. 16:32new uh folder uh tasks folder here just
  329. 16:36to make things a little more organized
  330. 16:39move there in here we're going to do
  331. 16:42event receive execute
  332. 16:46AI off of the controlled Pawn we're
  333. 16:49going to do c 2 BP
  334. 16:53neighbor and we're going to do a very
  335. 16:55simple simple thing here AI move
  336. 17:00to PA being DP neighbor the target actor
  337. 17:03being get player
  338. 17:08character
  339. 17:09and
  340. 17:11sometimes it will and sometimes it will
  341. 17:16fail
  342. 17:18and and uh we're going to want
  343. 17:25[Music]
  344. 17:27to actually
  345. 17:30let's make a new variable a new Boolean
  346. 17:33called uh hot
  347. 17:37[Music]
  348. 17:41player and we'll set that to True
  349. 17:43whenever he catches the uh the player
  350. 17:46but we're we haven't actually set that
  351. 17:48right now but we will later uh off of
  352. 17:50the cast in the task we're going to do
  353. 17:53get caught
  354. 17:56[Music]
  355. 17:57player and we're going to make a
  356. 18:01branch and if he hasn't caught the
  357. 18:04player he's going to try to move to them
  358. 18:09again again double click on the string
  359. 18:12to make a reroute
  360. 18:15node what is going on
  361. 18:19here there we
  362. 18:23go
  363. 18:25so once we once we get into the L sight
  364. 18:32here he actually doesn't move and
  365. 18:35there's a reason for
  366. 18:38that press P really quick what do you
  367. 18:43see oh I guess I already set that
  368. 18:46[Music]
  369. 18:48there uh so the reason actually isn't
  370. 18:50what I thought is because we're not
  371. 18:53actually triggering that in the task so
  372. 18:56attack Beauty task attack and now
  373. 19:02[Music]
  374. 19:04he's moving towards us
  375. 19:07nice however if you
  376. 19:13notice if you
  377. 19:15notice he his movement is a bit
  378. 19:19jittery he like snaps towards the uh his
  379. 19:24Destin his destination and of course
  380. 19:27there is a way way uh to make that a bit
  381. 19:31smoother however we have to do we have
  382. 19:33to enable and disable a couple first we
  383. 19:36have to you we have to turn off use
  384. 19:38controller rotation
  385. 19:40yaah and then in the character
  386. 19:43movement uh by the way that was in the
  387. 19:45uh the default character uh settings in
  388. 19:48the pawn
  389. 19:50here uh in and in the character movement
  390. 19:54uh component settings we want to scroll
  391. 19:56all the way down until we see character
  392. 19:58move
  393. 19:59movement and then we're going to want to
  394. 20:02check Orient rotation to
  395. 20:05movement and this setting right here the
  396. 20:08Z rotation setting that's that's
  397. 20:11basically this is basically how quickly
  398. 20:13he's going to move he's going to orient
  399. 20:16himself towards the uh the desired uh
  400. 20:20the desired path So currently it's very
  401. 20:23fast 360 it literally just means he'll
  402. 20:26just snap straight to it so let's set
  403. 20:29this
  404. 20:30to
  405. 20:33[Music]
  406. 20:37250 and he moves a lot
  407. 20:42[Music]
  408. 20:46smoother
  409. 20:49nice so now that that's done we got to
  410. 20:53make him actually catch the player
  411. 20:56because currently if he moves towards us
  412. 20:58he just
  413. 20:59stares at
  414. 21:01us actually let's let's do let's trigger
  415. 21:05this branch on success as
  416. 21:09[Music]
  417. 21:10well yeah there we go look at that look
  418. 21:14at that okay
  419. 21:20so now let's actually make him catch the
  420. 21:22player so we're going to make a box
  421. 21:24Collision component we we'll just call
  422. 21:27this catch box
  423. 21:29and then move this over here let's uh
  424. 21:33let's change the thickness to look like
  425. 21:38uh let's
  426. 21:41see about
  427. 21:44that actually it's a little too
  428. 21:46[Music]
  429. 21:48thin about that yeah that seems fine
  430. 21:51seems fine all right this will act as
  431. 21:54the HIIT box for his
  432. 21:57catching and
  433. 22:01so we also are going to want to do the
  434. 22:03do this on a vent Teck or on neighbor
  435. 22:05tick I guess in this in my case we're
  436. 22:08going to get
  437. 22:11catchbox is overlapping
  438. 22:15actor and with the with the other we're
  439. 22:17going to get
  440. 22:19player get player
  441. 22:21[Music]
  442. 22:24character and
  443. 22:29off of the TR the
  444. 22:31true if if the box is overlapping the
  445. 22:35character we're going to
  446. 22:37check if the player has if the AI has
  447. 22:42caught the player if it hasn't we're
  448. 22:45going to trigger a custom event because
  449. 22:47this is a very
  450. 22:49large uh this is a very large bit of
  451. 22:53functionality uh but before we do any of
  452. 22:55that let's actually comment stuff out
  453. 23:00just so that we are
  454. 23:05[Music]
  455. 23:13organized trigger
  456. 23:17[Music]
  457. 23:20attack oh oops yeah there we go
  458. 23:25[Music]
  459. 23:29make a custom
  460. 23:32event call a catch player and then right
  461. 23:36at the right at the start we're going to
  462. 23:39set catch player cop player to
  463. 23:44true and we'll actually trigger that
  464. 23:50here go and the the reason why we want
  465. 23:55to do this first is because since this
  466. 23:57is being triggered uh every1 seconds we
  467. 24:01don't want this to Loop and and since
  468. 24:04this is checking if he hasn't already
  469. 24:06caught the player if it's set to
  470. 24:10true it's just not going to do
  471. 24:13anything which is what we
  472. 24:15want so we also want to play a
  473. 24:22sound and uh let's see
  474. 24:26actually let's
  475. 24:29catch let's see which one of these do we
  476. 24:31want to want do we want to
  477. 24:33use uh you know what let's just make
  478. 24:36this more like the original uh hello
  479. 24:39neighbor we'll just use catch
  480. 24:41two now let's close the Bey task attacks
  481. 24:44cuz we're not going to do anything in
  482. 24:46that anymore for now we'll just use
  483. 24:48catch
  484. 24:50two so now if
  485. 24:56we look at that
  486. 25:00it plays the sound and everything but
  487. 25:01nothing nothing else actually happens
  488. 25:03however this we at least know it's
  489. 25:09trigger uh
  490. 25:12actually let's add a
  491. 25:17final let's actually add a final State
  492. 25:22here in the neighbor State we'll call
  493. 25:25this none
  494. 25:28[Music]
  495. 25:30and we'll only set this when
  496. 25:34uh and we'll only set this when uh when
  497. 25:38we want him to like do nothing
  498. 25:42essentially and have zero Behavior so in
  499. 25:47the event graph here we're going to
  500. 25:49do we're going to do one last thing here
  501. 25:52in the in the attack triggering
  502. 25:56part we're going to
  503. 25:59check
  504. 26:02if if the player has not been
  505. 26:07[Music]
  506. 26:10caught that
  507. 26:11way when he does catch the player uh
  508. 26:16Attack Mode is not going to be
  509. 26:20triggered and we can do we can be free
  510. 26:22to do whatever we
  511. 26:24want so now and now back in set State
  512. 26:30actually I don't
  513. 26:33think uh let's just set the max walk
  514. 26:36speed to
  515. 26:37[Music]
  516. 26:40100
  517. 26:41[Music]
  518. 26:42actually we'll just set it to zero
  519. 26:44because that'll work
  520. 26:46perfectly uh
  521. 26:50so actually we can use we can leave it
  522. 26:55as cool so let's set the stick
  523. 26:58State To
  524. 27:02None we'll
  525. 27:06play
  526. 27:09animation play
  527. 27:11animation search for
  528. 27:15choke cool so now when he catches
  529. 27:21us plays the animation but we also want
  530. 27:24the chase music to stop playing so in
  531. 27:27the set state
  532. 27:29let's get the chase music and just do
  533. 27:33[Music]
  534. 27:43stop there we
  535. 27:44[Music]
  536. 27:50go
  537. 27:53uh let's make the hatchbox a little bit
  538. 27:58[Music]
  539. 28:01bger there we go that's
  540. 28:03better okay so now he is playing the
  541. 28:09animation everything but we can still
  542. 28:11move around and
  543. 28:14[Music]
  544. 28:16everything which is not what we want so
  545. 28:21firstly we're going to get the player
  546. 28:24character
  547. 28:25[Music]
  548. 28:29uh
  549. 28:31disable
  550. 28:34input going to get the player
  551. 28:37controller and what this is going to do
  552. 28:40is it will disable all kinds of input
  553. 28:43from the
  554. 28:46player I can't see I can't do anything I
  555. 28:49can't I literally can't do
  556. 28:52anything it won't let me do anything
  557. 28:54which is what which is exactly what we
  558. 28:56want however
  559. 28:58there's one last there's the second to
  560. 29:01last part before the reset uh and it's
  561. 29:05the fact that if I look away from
  562. 29:07him it isn't turning towards him it the
  563. 29:12player camera is not turning to look at
  564. 29:14them so to to fix that and to implement
  565. 29:17that we're going to do add
  566. 29:21timeline we'll call this player
  567. 29:25rotate player oh whoops
  568. 29:32whoops open this call this Alpha shift
  569. 29:36click in here to add a key frame set the
  570. 29:38time to 0
  571. 29:40seconds and uh let's set it to
  572. 29:44be5
  573. 29:48seconds set time5 set it to
  574. 29:53one compile save close that that's all
  575. 29:57done actually we can close set status
  576. 30:00below and
  577. 30:03update now you might want to do
  578. 30:07something like set actor
  579. 30:10rotation and use a target for a player
  580. 30:15character you might want to do this for
  581. 30:19it however you don't want to do this
  582. 30:21actually and I'll show you why but first
  583. 30:24let's do
  584. 30:26[Music]
  585. 30:31th get get acor
  586. 30:37rotation so that as the a
  587. 30:41value and we want it to use the shortest
  588. 30:44path so it so it doesn't look weird uh
  589. 30:47when trust me trust me use shortest path
  590. 30:50you you'll want to turn that on for the
  591. 30:53B we going need to get look find Lookout
  592. 30:57rotation
  593. 31:00from the start we're going to do get
  594. 31:02actor
  595. 31:04[Music]
  596. 31:06location and at the Target we're going
  597. 31:08to copy and paste get actor location but
  598. 31:11we'll just leave this blank so that it
  599. 31:13is using the neighbor's location for the
  600. 31:16Target now again you don't actually want
  601. 31:20to use set actor rotation and the reason
  602. 31:23for that is
  603. 31:25because it actually doesn't really do
  604. 31:29anything and the reason for that is
  605. 31:32because this little setting right here
  606. 31:35use controller rotation yaw the player
  607. 31:38is also a character
  608. 31:40blueprint and it has this turned on by
  609. 31:45default so and that and that is actually
  610. 31:48needed in order to have like player
  611. 31:50input and everything so to fix that uh
  612. 31:55and so so to uh
  613. 31:57[Music]
  614. 31:59to make it so that we can actually
  615. 32:01rotate the player we're going to not use
  616. 32:04set actor
  617. 32:05rotation instead we're going to get the
  618. 32:08player
  619. 32:11controller we're going to do get control
  620. 32:15rotation we'll use that as the as the
  621. 32:19start instead and we'll
  622. 32:22do and then we'll do set control
  623. 32:26rotation
  624. 32:33and we'll connect that to there now when
  625. 32:36we do when we P
  626. 32:39play there we go look at
  627. 32:41[Music]
  628. 32:45that I can be running away from oh no oh
  629. 32:48no he's going to get me oh he got
  630. 32:52me if you want to make it slower you can
  631. 32:56if you want to make the turn slower you
  632. 32:57can set the length to one or
  633. 33:00something set the
  634. 33:02time
  635. 33:07one yeah oh no he's going to get
  636. 33:11me I think that looks nicer actually so
  637. 33:13we're going to keep it that way we're
  638. 33:14going to keep it one
  639. 33:16second uh so now finally for the
  640. 33:23resetting uh let's
  641. 33:25actually Comet this out we'll call this
  642. 33:29rotate
  643. 33:31[Music]
  644. 33:35layer and off of this we're going to do
  645. 33:38a sequence
  646. 33:39node I'm going to set a delay make a
  647. 33:43delay node for one second now you may be
  648. 33:45wondering why would we not just use the
  649. 33:48finished uh pin here on the on the
  650. 33:51timeline for whatever
  651. 33:54reason uh I'm sure there's probably some
  652. 33:58I'm missing or something but for some
  653. 34:00reason this pin triggers
  654. 34:05way late after the timeline is actually
  655. 34:08finished triggering when it it has
  656. 34:11actually gone through the entire
  657. 34:12animation for whatever reason it just
  658. 34:15does not trigger on time at all so we're
  659. 34:18just going to use a Delano
  660. 34:20instead now there are a couple ways you
  661. 34:24can do the
  662. 34:25reset uh you can just use uh open level
  663. 34:32and uh and just and just uh do
  664. 34:39like yeah you can just do like open
  665. 34:42level and use the current level name and
  666. 34:44just reopen the level however we don't
  667. 34:47really want that because that completely
  668. 34:49resets all of your progress and of
  669. 34:51course nobody wants that so instead
  670. 34:54we're just going to do uh get all
  671. 34:57widgets of
  672. 34:59class going to do we're going to get the
  673. 35:02fade for each
  674. 35:06Loop fade
  675. 35:09anim forward so that now when we do
  676. 35:16play it'll
  677. 35:18fade uh you know what the camera keeps
  678. 35:21clipping inside of him for whatever
  679. 35:23reason so let's just add one extra new
  680. 35:27and do set movement
  681. 35:33mode and just leave it as nut so that he
  682. 35:37immediately stops in his
  683. 35:42tracks or we can probably just just make
  684. 35:48it or we can probably just make it
  685. 35:51bigger
  686. 35:52[Music]
  687. 35:59cool so I don't think that was even
  688. 36:03needed I I don't think that was even
  689. 36:06needed oh what the heck I didn't mean to
  690. 36:08do
  691. 36:09[Music]
  692. 36:17that you know what let's make this
  693. 36:2305
  694. 36:26.01 St
  695. 36:31okay there we go now it's more
  696. 36:36[Music]
  697. 36:40accurate Okay cool so now it actually
  698. 36:44like Fades into black after he catches
  699. 36:48you uh
  700. 36:50however uh we're going to have to make
  701. 36:53him actually reset your
  702. 36:56locations so to do that we're going to
  703. 36:59want to create two more
  704. 37:03variables we'll call this NE reset
  705. 37:09transform and let's set this to
  706. 37:13transform make another one call this
  707. 37:15player reset Point
  708. 37:19form and and make both of these public
  709. 37:22so that we can edit these in the level
  710. 37:25editor like so
  711. 37:28uh and to add a little bit more uh
  712. 37:31customization or like organization I
  713. 37:33should say let's make the category to
  714. 37:37[Music]
  715. 37:38uh game
  716. 37:41play add that
  717. 37:51there make an AI
  718. 37:53category change that just set all those
  719. 37:57there there go now what we're going to
  720. 38:00do is after after uh after a few seconds
  721. 38:05of uh being faded to Black let's make a
  722. 38:095
  723. 38:11Seconds let's uh we're going to fade uh
  724. 38:15fade back and the player and the
  725. 38:19neighbor will be reset to uh to specific
  726. 38:23locations uh let's just bring in an
  727. 38:25empty character just to have
  728. 38:29let's have the neighbor reset here so
  729. 38:34let's copy the uh the location the
  730. 38:37rotation it's just
  731. 38:39180 and we'll go to neigh res set
  732. 38:44transform paste the location set to
  733. 38:50180 cool and uh let's delete that
  734. 38:58and we'll put the player
  735. 39:02here copy location we don't need to copy
  736. 39:06the rotation because it's just 0 0
  737. 39:090 so now these two are primed and ready
  738. 39:14to use for the uh for the catching
  739. 39:19sequence let's delete that really
  740. 39:23[Music]
  741. 39:25quick now
  742. 39:28after 5 Seconds going
  743. 39:32to we're going to
  744. 39:38actually let's just have it do this
  745. 39:41again so we don't have to trigger a four
  746. 39:44loop again do
  747. 39:48reverse then after 5
  748. 39:51Seconds let's do set actor
  749. 39:55transform uh set actor trans
  750. 39:58transform and in game play neighbor
  751. 40:01reset
  752. 40:04transform and we'll do this
  753. 40:07again for the player
  754. 40:13character player reset
  755. 40:15[Music]
  756. 40:19transform so
  757. 40:23[Music]
  758. 40:25now it's going to fit f 1 2 3 4
  759. 40:325 there we
  760. 40:35go oh right I
  761. 40:37forgot silly me we have to set the
  762. 40:42control rotation see even I
  763. 40:46forget we're going to have to set the
  764. 40:48only set the players
  765. 40:51location set actor location nope not off
  766. 40:56set set actor
  767. 40:58location there we
  768. 41:03go and we're going to split this that
  769. 41:08that double click for reroute
  770. 41:10node there we
  771. 41:15go and we're going
  772. 41:19to he catches
  773. 41:22Us 2 three four five
  774. 41:27and we have re and we have both reset to
  775. 41:31the locations however we're going to
  776. 41:33want to do a few more things
  777. 41:36last lastly we're going to want to
  778. 41:39reenable the input for
  779. 41:47the just control
  780. 41:51again and we're going to want
  781. 41:55to set the AI State back to
  782. 41:59[Music]
  783. 42:01idle and we're gonna want to reset his
  784. 42:04animation mode his mesh's animation mode
  785. 42:07use the animation blueprint because when
  786. 42:10you use a uh play animation node it sets
  787. 42:15the the animation mode for the for the
  788. 42:19mesh to use animation asset so it's not
  789. 42:22going to be using the animation
  790. 42:24blueprint we want to reset that
  791. 42:27here with set animation
  792. 42:30mode cool so
  793. 42:35now uh actually we're going to want to
  794. 42:37do some things CL we're going to set cot
  795. 42:41player to
  796. 42:47balls and yeah that's that's pretty much
  797. 42:50it that's pretty much it for that I
  798. 42:53think let's see Catches Us
  799. 42:58[Music]
  800. 43:07[Music]
  801. 43:09excuse
  802. 43:10[Music]
  803. 43:14me
  804. 43:18huh I
  805. 43:23think okay
  806. 43:28let's make a delay node for
  807. 43:34like the freak oh I spawned right on top
  808. 43:38of him that's what it
  809. 43:40[Music]
  810. 43:46was there we go that's
  811. 43:49better so what was happening was
  812. 43:52uh basically the AI was was was like Reg
  813. 43:57string the player has
  814. 43:59seen uh just for a split second before
  815. 44:03uh
  816. 44:05before before uh being reset so just
  817. 44:10delaying this and turning off turning
  818. 44:12off a cop player prevented this from
  819. 44:14triggering
  820. 44:16again why was he not chasing us I have
  821. 44:18no freaking clue but it
  822. 44:21works it works completely fine he
  823. 44:24catches us fites to BL back bit's back
  824. 44:28after a few
  825. 44:30seconds we can move and
  826. 44:33everything he can chase us again I
  827. 44:37[Music]
  828. 44:38[Applause]
  829. 44:39[Music]
  830. 44:44think what's going on here oh my gosh I
  831. 44:49this is this this is my second time of
  832. 44:51re-record okay so this is my second time
  833. 44:53of re-recording this and I I made the
  834. 44:57exact same mistake twice in a
  835. 45:01row the reason why it's not working like
  836. 45:04this is
  837. 45:06because we're not setting the current
  838. 45:09state I I watch this I guarantee you
  839. 45:12it's going to work
  840. 45:14now I guarantee you it's going to work
  841. 45:19now so now we can go
  842. 45:24see see
  843. 45:27works now
  844. 45:33awesome
  845. 45:37so yep look at that he can chase us
  846. 45:41catch
  847. 45:43fade fade back we can move can pick up
  848. 45:48items and
  849. 45:50everything he can chase us
  850. 45:53again he can chase us again Fade to back
  851. 46:01there we go
  852. 46:03so we got to do one last
  853. 46:06thing and that is allowing the AI to
  854. 46:10lose the player uh but first let's
  855. 46:14select all
  856. 46:16this comment it out catching
  857. 46:20[Music]
  858. 46:32uh come with this
  859. 46:34[Music]
  860. 46:41out res set player and
  861. 46:46neighbor set player and
  862. 46:49neighbor let's actually move
  863. 46:53this let's actually move this down a bit
  864. 46:59[Music]
  865. 47:06there we
  866. 47:06[Music]
  867. 47:09go cool cool cool cool
  868. 47:12[Music]
  869. 47:15so
  870. 47:19let's
  871. 47:21Okay
  872. 47:23so actually let's go ahead and split
  873. 47:26this
  874. 47:28up if C
  875. 47:32flare if C player not is true then it's
  876. 47:37going to check
  877. 47:40if it's going to check cany player if
  878. 47:43it's
  879. 47:44false going to do a branch we'll
  880. 47:47actually put this over here and a
  881. 47:51reroute
  882. 47:52node and then we're going to get the
  883. 47:54current state
  884. 47:57check if it's equal
  885. 47:59to
  886. 48:05attack uh if it's true we're going to
  887. 48:11do we're going to do a retriggerable
  888. 48:15delay or
  889. 48:27actually we can there's a better way for
  890. 48:28us to do this we're going to use a
  891. 48:34gate and
  892. 48:36if and if the a AI can't see the player
  893. 48:41it's going to open
  894. 48:44this and it's and that's going to be
  895. 48:47enter but if you can't see the player
  896. 48:49it's going to close
  897. 48:52this and going do a retriggerable delay
  898. 48:58and we'll set this to 8 seconds this
  899. 48:59will Bas basically be however long you
  900. 49:02want the AI to wait before it can lose
  901. 49:05the player you can promote this to a
  902. 49:08variable instead it to like a I don't
  903. 49:10know
  904. 49:12it uh lose player
  905. 49:18time and set this to to public set it
  906. 49:23put this an
  907. 49:25AI the default is 8 seconds we're just
  908. 49:28going to keep this as a as a public uh
  909. 49:31variable just to make this uh things a
  910. 49:33little bit easier or just to make that
  911. 49:36add a little bit more
  912. 49:38customization for each
  913. 49:40level
  914. 49:42[Music]
  915. 49:45and and after 8
  916. 49:48seconds we're going to do
  917. 49:51one last
  918. 49:54Branch we're going to check
  919. 49:57if cany
  920. 49:59player is still
  921. 50:02false if it
  922. 50:04is if it is
  923. 50:06still
  924. 50:08[Music]
  925. 50:12false
  926. 50:14and current state is equal to attack
  927. 50:27we'll actually use a
  928. 50:29not not
  929. 50:34boan if both of those are true then it's
  930. 50:38going to set the state to
  931. 50:41hunt and we're going to do one last
  932. 50:43thing this is in regards to the chase
  933. 50:47music uh in
  934. 50:50Hunt we're actually going to
  935. 50:54also stop stop the chase
  936. 51:01music but we're also going to
  937. 51:04do last
  938. 51:06thing we're going to add an audio
  939. 51:09component we're going to call
  940. 51:12this I'm going to call this hunt
  941. 51:17music and we're going to use
  942. 51:21the where is
  943. 51:23it near hunt
  944. 51:27we're going to use near hunt
  945. 51:29q but we have to
  946. 51:32do we're we have to
  947. 51:35do
  948. 51:37uh attenuation
  949. 51:40distance volume
  950. 51:42attenuation going to override the
  951. 51:47attenuation
  952. 51:50and volume attenuation spatialization
  953. 51:53we're going to disable
  954. 51:55spatialization that that
  955. 51:57way uh we're actually going to uh here
  956. 52:06on uh let's actually make
  957. 52:10the make a 2,000 4 and
  958. 52:14400 uh 2 uh 2,000 is still really really
  959. 52:18far really really
  960. 52:23far so that
  961. 52:25way with uh spatialization turned
  962. 52:28[Music]
  963. 52:32off it'll get quieter and louder
  964. 52:36depending on how close we are to the
  965. 52:40AI actually that
  966. 52:44600 got 200 so okay yeah that seems that
  967. 52:48seems fine uh so now we're just going to
  968. 52:52turn off auto activate
  969. 52:56and we're going to do a couple things in
  970. 52:58the set State function we're going to
  971. 53:00first we're going to make we're going to
  972. 53:03make it we're going to do the same
  973. 53:06thing check if it is it isn't already
  974. 53:10playing if it isn't play
  975. 53:15[Music]
  976. 53:20it and off of Attack Mode when in attack
  977. 53:24mode it's going to oh not stop delayed
  978. 53:28stop it's just going to
  979. 53:34stop uh actually since actually we're
  980. 53:38going to fade we're actually going to
  981. 53:40fade
  982. 53:44out uh Fade Out duration think A5
  983. 53:51seconds
  984. 53:53cool so
  985. 53:57uh let's see is the AI able to move up
  986. 54:00here he can't move up here fantastic so
  987. 54:04what we're going to do test this let's
  988. 54:07go up
  989. 54:08[Music]
  990. 54:11here it should be setting to hunt after
  991. 54:148
  992. 54:21seconds oh
  993. 54:26[Music]
  994. 54:37uh you know what let's get rid of the
  995. 54:39gate get rid of all this
  996. 54:44BS get rid of all this BS instead of a
  997. 54:47retriggerable delay let's just do a
  998. 54:49regular delay
  999. 54:50[Music]
  1000. 55:01so
  1001. 55:02[Music]
  1002. 55:06now he starts chasing
  1003. 55:09us 3 2
  1004. 55:14[Music]
  1005. 55:221 now he's in Hunt mode currently
  1006. 55:26[Music]
  1007. 55:28but when we go back into his L
  1008. 55:31sight what the where did I just go what
  1009. 55:34just happened to
  1010. 55:36me uh goodness gracious this house this
  1011. 55:39House's model is very
  1012. 55:42buggy
  1013. 55:43so 5 4 3 2 1 there we go now we run back
  1014. 55:52here he starts chasing us again
  1015. 55:55[Music]
  1016. 56:00cool and that is basically it uh really
  1017. 56:05the largest and most complicated part of
  1018. 56:08this entire thing is the catching but
  1019. 56:12even then it's not as it's not like
  1020. 56:15insanely complex I I would like I would
  1021. 56:18like to think this is the uh the AI
  1022. 56:22video uh next updated video next remas
  1023. 56:27uh AI tutorial will be the hunt mode and
  1024. 56:30it's not just going to be part one we're
  1025. 56:33going to do the entire thing we're going
  1026. 56:35to make the entire
  1027. 56:37framewor and uh it's only going to
  1028. 56:41consist of like one maybe two tasks I
  1029. 56:44don't know I'll have to figure it out
  1030. 56:46later but yeah I hope you were able to
  1031. 56:48follow this and uh Happy programming I
  1032. 56:52guess
  1033. 56:56a

About this transcript

This page contains the full transcript of Hello Neighbor UE4 AI Tutorial #1 | Chase and Catch (REMAKE) by Owen Campos, generated from the public captions YouTube serves with the video. The transcript has 5,848 words across 1,033 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.