Check for NULL objects

This commit is contained in:
rodolpheh 2023-11-13 21:50:47 +00:00
parent 1fadb5bd21
commit 10aa7152f2
3 changed files with 20 additions and 2 deletions

View File

@ -27,6 +27,7 @@ func _ready():
func _process(_delta):
if tracking == null:
skeleton.hide()
return
if Engine.is_editor_hint() and not tracking.run_in_editor:
@ -35,6 +36,9 @@ func _process(_delta):
return
var frame : UltraleapFrame = tracking.get_last_frame()
if frame == null:
skeleton.hide()
return
if use_interpolation:
var interpolated_frame : UltraleapFrame = tracking.get_interpolated_frame(Time.get_ticks_usec())
if interpolated_frame != null:

View File

@ -29,6 +29,9 @@ func _process(_delta):
image = tracking.get_right_image() if side == Side.Left else tracking.get_left_image()
else:
image = tracking.get_right_image() if side == Side.Right else tracking.get_left_image()
if image == null:
return
# Get image size
var image_size : Vector2i = image.get_size()

View File

@ -11,8 +11,9 @@ func _ready():
var scene : PackedScene = preload("res://models/Origin.tscn")
dry_run = true
var n : int = set_hand(tracking.get_last_frame().left_hand, 0)
n = set_hand(tracking.get_last_frame().right_hand, n)
var new_frame : UltraleapFrame = UltraleapFrame.new()
var n : int = set_hand(new_frame.left_hand, 0)
n = set_hand(new_frame.right_hand, n)
dry_run = false
print(str(n) + " bones")
@ -26,6 +27,16 @@ func _ready():
func _process(_delta):
var n : int = 0
if tracking == null:
return
var frame : UltraleapFrame = tracking.get_last_frame()
# Dirty hack to check if the device is initialised.
# Should implement something like a flag later
if frame == null:
return
if use_interpolation:
var interpolated_frame : UltraleapFrame = tracking.get_interpolated_frame(Time.get_ticks_usec())