Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Zubayer |
(these 2 lines is not apart of the code) there are underscores in the code but for some reason, they don’t show.
extends KinematicBody2D
const GRAVITY = 15
const ACCELARATION = 50
const MAX_SPEED = 200
var enemy = self
var speed = 15
onready var target = get_parent().get_node(“player”)
func _ready():
set_physics_process(true)
pass
func _fixed_process(delta):
var direction = (target.get_global_transform().x - enemy.get_global_transform()).normalized()
move_and_collide(direction*speed)
pass
When you’re posting code here, either put four spaces in front of each line, or use the code formatting button, which looks like {}
kidscancode | 2018-07-03 20:48
When you’re posting code here, either put four spaces in front of each line, or use the code formatting button, which looks like {}
Also, if you’re using 3.0, you don’t need set_physics_process(true)
. And those pass
statements are meaningless and don’t do anything at all.
kidscancode | 2018-07-03 20:50