【发布时间】:2022-02-04 11:51:14
【问题描述】:
当玩家在左侧时,我游戏中的敌人不会向左移动,而是会向右移动。然后当玩家在右边时,敌人会向玩家移动。
敌人的代码:
extends KinematicBody2D
var run_speed = 100
var velocity = Vector2.ZERO
var collider = null
func _physics_process(delta):
velocity = Vector2.ZERO
if collider:
velocity = position.direction_to(collider.position) * run_speed
velocity = move_and_slide(velocity)
func _on_DetectRadius_body_entered(body):
collider = body
func _on_DetectRadius_body_exited(body):
collider = null
【问题讨论】:
标签: godot