Skip to content

Raycast against terrain3D at -x yields no/error results? #548

Closed Answered by TokisanGames
andreasng asked this question in Questions
Discussion options

You must be logged in to vote

I have no problem running this in 4.3 using the demo, player.gd:

func _physics_process(p_delta) -> void:
	...
	print(raycast_to_world(global_position))

func raycast_to_world(start_position: Vector3) -> Vector3:
	var ray_params = PhysicsRayQueryParameters3D.new()
	ray_params.from = start_position + Vector3(.0, 1., .0)
	ray_params.to = start_position + Vector3(.0, -1000., .0)
	var space_state = get_world_3d().direct_space_state
	var result = space_state.intersect_ray(ray_params)
	print(result)
	if result:
		return result.position
	else:
		print("raycast failed!")
		return Vector3.INF

There's no crash if the raycast doesn't hit or in -X. If there's a region it prints the hit without issue:

{…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@andreasng
Comment options

@andreasng
Comment options

@andreasng
Comment options

@TokisanGames
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by TokisanGames
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants