Spawned mob stuck on the screen edge

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tuan

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():
var mob = Mob.instance()
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

:bust_in_silhouette: Reply From: Becbunzen

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:


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

tuan | 2020-06-05 15:30