0 votes

I follow your first game instruction here
but some time when i test my game, mob was stuck on the screen edge, some time it is running properly. Please help me fix this problem
I tried to restart my laptop, turn it off but can't. Debugger did not show any notice
Some time it is be running normally after i turn off laptop for few hour

func _on_MobTimer_timeout():
$MobPath/MobSpawnLocation.set_offset(randi())
var mob = Mob.instance()
$MobContainer.add_child(mob)
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
mob.position = $MobPath/MobSpawnLocation.position
direction += rand_range(-PI / 4, PI / 4)
mob.rotation = direction
mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED, mob.MAX_SPEED), 0).rotated(direction))

Thanks you

in Engine by (28 points)
recategorized by

1 Answer

0 votes
Best answer

I think you are missing a line at the end:

mob.linear_velocity = mob.linear_velocity.rotated(direction)

Or in the way you have done it:

mob.set_linear_velocity(mob.linear_velocity.rotated(direction))
by (154 points)
selected by

Thanks you for your answer. I missing that line :D

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 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 webmaster@godotengine.org with your username.