Godot Version
3.2.3
Question
Hi everyone,
i’m recreating arkanoid on godot, and i have a weird bug. Both the platform (vaus) and the powerups falling from destroyied blocks are using move_and_collide: the first to detect collisions with ball and powerups and the latter to be destroyied when goin out the screen.
However, it happens that if the platform is still when the powerup touches it the collision is registered, instead if the platform moves while the powerup touches, the platform slides under it and as soon as the powerup can move it continues descending.
Content not found | LimeWire (example video)
platform code:
func _physics_process(delta: float) -> void:
if (not global_node.running):
ball.global_position = self.global_position + Vector2(0.0, -30.0)
velocity = calculate_velocity()
var body = move_and_collide(velocity * delta)
# Collision with powerup
# Body.collider is the object is colliding with
if body and body.collider.is_in_group("powerups"):
body.collider.queue_free()
activate_powerup(body.collider.type)
sound_player.play_sound(sound_player.supported_audio.POWERUP);
powerup code
func _on_DebugTimer_timeout():
print_debug("spawned powerup");
var temp = powerup.instance();
temp.global_position = Vector2(self.position.x, self.position.y + OFFSET);
temp.type = global_node.powerup_type[rand_range(0, global_node.powerup_type.size() - 1)];
get_parent().add_child(temp);
What could be the reason?
Thanks in advance