I'm making a 2d top-down game in Godot 4 with C# and I can't get the enemy AI to move toward the player. The only time it follows the player is when the player in under the enemy and touching the enemy.
I'm making a 2d top-down game in Godot 4 with C# and I can't get the enemy AI to move toward the player. The only time it follows the player is when the player in under the enemy and touching the enemy.
This is my code for the enemy movement: [code]public override void _PhysicsProcess(double delta) { Move(); MoveAndSlide(); } public void Move() { if (_player != null) { LookAt(_player.GlobalPosition); Vector2 direction = (GlobalPosition - _player.GlobalPosition).Normalized(); Velocity = direction * Speed; } else { Velocity = Vector2.Zero; } } [/code]
Я пытаюсь сделать так, чтобы противник отходил назад и перестраивался с одной позиции на другую. Я использую метод пинг-понга, но он не работает.
public class Enemy : MonoBehaviour
{
public float movementSpeed = 5.0f;
Я пытаюсь сделать так, чтобы противник отходил назад и перестраивался с одной позиции на другую. Я использую метод пинг-понга, но он не работает.
public class Enemy : MonoBehaviour
{
public float movementSpeed = 5.0f;
Сначала я показываю руководство по Space, которое создает 2 узла и передает их.
Затем я использую SimulateKeyPressed в SceneRunner , чтобы автоматизировать нажатие клавиши, при этом второй узел не создается. Вместо этого я вижу (фокус не...
Я следил за несколькими источниками, чтобы создать свою собственную StateMachine в Unity Engine без каких-либо подсостояний. Мне удалось создать StateMachine, которая отвечает всем основным и простым требованиям персонажа в видеоигре, таким как...