Godot version 4.3 stable_mono_win64
I’m having a problem where closing the game will cause the game to freeze my entire computer for a few seconds, close the editor and turn the game from a fullscreen to a windowed application. I’ve tried using both GetTree().Quit(); and GetTree().CallDeferred(“quit”); and both give the same result.
Heres the code:
using Godot;
using System;
public partial class Player : CharacterBody2D
{
[Export]
public float Speed = 300.0f;
[Export]
public float JumpVelocity = -400.0f;
[Export]
public float DownVelocity = 400.0f;
public bool isFalling = false;
public override void _PhysicsProcess(double delta)
{
Vector2 velocity = Velocity;
if (!IsOnFloor())
{
velocity += GetGravity() * (float)delta;
}else{
isFalling = false;
}
if (Input.IsActionJustPressed("up") && IsOnFloor())
{
velocity.Y = JumpVelocity;
}
if (Input.IsActionPressed("down") && !IsOnFloor())
{
isFalling = true;
}
if (isFalling)
{
velocity.Y += DownVelocity;
}
Vector2 direction = Input.GetVector("left", "right", "up", "down");
if (direction != Vector2.Zero)
{
velocity.X = direction.X * Speed;
}
else
{
velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed);
}
Velocity = velocity;
MoveAndSlide();
}
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("ui_cancel"))
{
GetTree().CallDeferred("quit");
}
}
}
which is attached to the Player, and
using Godot;
using System;
public partial class World : Node2D
{
public override void _Ready()
{
GetNode<Area2D>("killZone").BodyEntered += OnKillZoneBodyEntered;
GetNode<Area2D>("WinZone").BodyEntered += OnWinZoneBodyEntered;
}
private void OnKillZoneBodyEntered(object body)
{
if (body is Player player)
{
GetTree().ReloadCurrentScene();
}
}
private void OnWinZoneBodyEntered(object body)
{
if (body is Player player)
{
GetTree().ChangeSceneToFile("res://Scenes/Levels/Level1.tscn");
}
}
}
which is attached to the root of the current scene.
It only seems to happen after I’ve reloaded the current scene, and when it happens seems wildly inconcistent, and it once even caused a blue screen. Thanks for any help