У нас вы можете посмотреть бесплатно Top Down 4 Directional NPC Chase Script - Defold 2D Tutorial 7 или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
I show how to make a simple 4 Directional Chase Script for top down 2d games. Script: Greater than and Less than signs not allowed in description. function init(self) self.pc_postion = vmath.vector3() --initialize player position self.my_position = vmath.vector3() -- initialize this position self.dist = vmath.vector3() --initialize distance from player self.in_dir = vmath.vector3() self.speed = 80 self.allowd =10 -- distance close enough to player end function update(self, dt) self.pc_postion = go.get_position("PlayerCharacter") self.my_position = go.get_position() self.dist = self.pc_postion - self.my_position -- Up Down Follow if math.abs(self.dist.y) greater than self.allowd then if self.dist.y greater than self.allowd then self.in_dir.y = self.speed elseif self.dist.y less than -self.allowd then self.in_dir.y = -self.speed end else self.in_dir.y = 0 --make sure to reset value on false end --Always Close Vertical Distance Before Closing Horizontal Distance --Left Right Follow if math.abs(self.dist.x) greater than math.abs(self.dist.y) and math.abs(self.dist.x) greater than self.allowd and math.abs(self.dist.y) less equal self.allowd then if self.dist.x greater than self.allowd then self.in_dir.x = self.speed elseif self.dist.x less than -self.allowd then self.in_dir.x = -self.speed end else self.in_dir.x = 0 --make sure to reset value end go.set_position(go.get_position() + self.in_dir * dt) end end