Skip to content

Fix few value is null cases I found. - #724

Open
pietru2004 wants to merge 2 commits into
GodotVR:masterfrom
pietru2004:pietru2004-patch-1
Open

pietru2004 wants to merge 2 commits into
GodotVR:masterfrom
pietru2004:pietru2004-patch-1

Conversation

@pietru2004

@pietru2004 pietru2004 commented May 2, 2025

Copy link
Copy Markdown
Contributor

I was testing my game and got variable is null errors at
var obj = with.get_collider()
ground_node = ground_collision.get_collider()
var collision_node := collision.get_collider()

Added variable!=null checks before code parts that would use those...

Hope those are good...

@pietru2004 pietru2004 changed the title fix some value is null cases Fix few value is null cases I found. May 2, 2025

@BastiaanOlij BastiaanOlij left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than some nitpicks on the syntax, this looks good. I do question the ground physics change though, might need @Malcolmnixon to weigh in.

Comment thread addons/godot-xr-tools/player/player_body.gd Outdated
# Select the ground physics
var physics_node := ground_node.get_node_or_null("GroundPhysics") as XRToolsGroundPhysics
ground_physics = XRToolsGroundPhysics.get_physics(physics_node, default_physics)
if ground_node!=null:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, just change to if ground_node:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(though if I am not mistaken, XRToolsGroundPhysics.get_physics already does a null check and returns default_physics if physics_node is not usable, so possibly this fix is incorrect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK about XRToolsGroundPhysics.get_physics, but when I was developing my project it was one of points where I got null exception so mayby it failed to do so ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'd like to get @Malcolmnixon reaction on this bit then. I think its supposed to work so there may be a bug that needs fixing. Else we may end up disabling the default physics logic.

Comment thread addons/godot-xr-tools/player/player_body.gd Outdated
@BastiaanOlij BastiaanOlij added the bug Something isn't working label May 19, 2025
@BastiaanOlij BastiaanOlij added this to the 4.4.1 milestone May 19, 2025
@pietru2004
pietru2004 requested a review from BastiaanOlij May 19, 2025 06:10
@pietru2004

Copy link
Copy Markdown
Contributor Author

removed those 3 !=null

@BastiaanOlij BastiaanOlij modified the milestones: 4.4.1, 4.5.0 Sep 26, 2025
# Update ground velocity information
_previous_ground_node = ground_node
_previous_ground_global = ground_collision.get_position()
_previous_ground_local = ground_node.to_local(_previous_ground_global)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs an else so that if we don't have a ground node, we don't keep some old ground node in the previous values.

Other than that, this looks good now.

@BastiaanOlij BastiaanOlij modified the milestones: 4.5.0, 4.6.0 Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants