Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | HarryCourt | |
Old Version | Published before Godot 3 was released. |
So, I have some zombies, which their default sprite is them looking left (Ignore the glitches):
However, when I go to the left of the map, zombies are looking the other way:
Here’s the script to one of the zombies, they almost have the same script btw:
extends KinematicBody2D
const GRAVITY = 60
onready var zombie = self
var speed = 0.5
var velocity = Vector2()
onready var target = get_parent().get_node("Player")
export var ZombieSpeed = 1500
export var Smoothness = 0.2
func _ready():
set_fixed_process(true)
#self.add_collision_exception_with(Boundry)
func _fixed_process(delta):
var direction = (target.get_global_pos() - zombie.get_global_pos()).normalized()
velocity.y += GRAVITY
#move(direction*speed*delta)
var motion = velocity * speed * delta
motion = move(motion)
velocity.x = lerp(velocity.x, ZombieSpeed * direction.x, Smoothness)
if (is_colliding()):
var normal = get_collision_normal()
motion = normal.slide(motion)
velocity = normal.slide(velocity)
var collider = get_collider()
move(motion)
if (collider.is_in_group("Bullet")):
queue_free()
print("Zombie3 Killed!")
if (collider.is_in_group("AutoKill")):
queue_free()
print("Zombie3 Killed by Boundry!")