Script freezing game - help

Godot Version

4.3

Question

I’ve got this script attached to a Node2D:

extends Node2D

var touch: InputEventScreenTouch

func _ready() -> void:
	touch = InputEventScreenTouch.new()
	touch.pressed = true
	touch.position = global_position*get_viewport_transform()
	Input.parse_input_event(touch)

When I instantiate the node, the game freezes.
Can anybody tell me what is going on there?
Thanks in advance!

Is the freeze actually a stack trace? can you tab back into the editor and see a error message?

On Android or on which operating system?

just debug started from the editor

And no weird error messages

ok actually it doesn’t freeze like this:

extends Node2D

var touch: InputEventScreenTouch

func _ready() -> void:
	touch = InputEventScreenTouch.new()
	touch.pressed = true
	touch.position = global_position*get_viewport_transform()
	#Input.parse_input_event(touch)

Aha! This worked:
extends Node2D

var touch: InputEventScreenTouch

func _ready() -> void:
	touch = InputEventScreenTouch.new()
	touch.pressed = true
	touch.position = global_position*get_viewport_transform()
	Input.parse_input_event.call_deferred(touch)

Thanks anyway!

1 Like