Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better input picking for GUI in 3D demo #769

Open
Zireael07 opened this issue Aug 30, 2022 · 0 comments
Open

Better input picking for GUI in 3D demo #769

Zireael07 opened this issue Aug 30, 2022 · 0 comments

Comments

@Zireael07
Copy link

Which demo project is affected:
GUI in 3D

Description:
As implemented, the raycast can miss the gui since the area is very thin on Z axis. If one makes it "thicker", it will result in offset clicks, the bigger the Z axis of the area, the bigger the offset.

My solution:

# https://github.com/godotengine/godot/issues/21113#issuecomment-413839581
static func plane(normal: Vector3, p: Vector3) -> Plane:
	var n = normal.normalized()
	return Plane(n, p.dot(n))

# adjust normal to how your mesh points in global space
var plan = plane(Vector3(0,0,1), $Quad.global_transform.origin)
# you still need a ray of some sort, but instead of doing ray.get_collision_point() do this:
var cursor = plan.intersects_segment(ray.global_transform.origin, ray.global_transform * ray.cast_to)

Tested and it gets rid of the annoying offsets <3 <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant