This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Well, I'm creating a game with blocks, like a maze. Where I have my character who must go through the enemies and reach the end of the stage.
But my enemy has a bug and sometimes invades the blocks and goes crazy. I'll post a video reporting the error and the code made.
I'm Brazilian so maybe my English isn't perfect.
This is my code:

extends StaticBody2D

const DOWN = 0
const RIGHT = 1
const UP = 2
const LEFT = 3

export var speed = 200
export var health = 1
var velocity = Vector2()
var movedirection = -1
var direction
var steps
var count
steps

func ready():
randomize()
_new
goal()

func newgoal():
direction = randi() % 4
steps = 50 + (randi() % 50)
count_steps = 0

func process(delta):
count
steps += 1
if countsteps > steps:
_new
goal()
if direction == DOWN:
velocity.y = speed
rotationdegrees = 0
elif direction == RIGHT:
velocity.x = speed
rotation
degrees = -90
elif direction == UP:
velocity.y = -speed
rotationdegrees = 180
elif direction == LEFT:
velocity.x = -speed
rotation
degrees = 90
if velocity.length() > 0:
pass

Godot version 3.5
in Engine by (12 points)

1 Answer

0 votes

Se postar o vídeo ou um gif ajudaria a ter mais informações do problema.

Talvez seja o "extends StaticBody2D" se fosse um area2D ou um kinematicBody2D pode ser que resolva o problema.

by (286 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.