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

Add two-hand pickup and ability of switching hand while grabbing #554

Closed
fangzhangmnm opened this issue Oct 18, 2023 · 4 comments
Closed

Comments

@fangzhangmnm
Copy link

fangzhangmnm commented Oct 18, 2023

One might see my old Unity3D code

For two-handed weapons one might want to add the two-hand pickup ability
Also one might want to use another hand to grab the object while holding the object with one hand

@fangzhangmnm fangzhangmnm changed the title Add two-hand pickup and switch hand Add two-hand pickup and ability of switching hand while grabbing Oct 18, 2023
@DigitalN8m4r3
Copy link
Contributor

there is some work being done behind the curtain, an example of twohanded can be seen in my closed pr
#478

The collision hands are partially now part of the xr tools.
Feel free to look the things up and u are very welcome to implement your ideas and share them if u feel comfortable to do so.
After all the godot xr tools are heavily driven by the community

@DigitalN8m4r3
Copy link
Contributor

DigitalN8m4r3 commented Oct 19, 2023

on a furhter note, there is a simplified way to add twohanded just by editing one file
the interactable_handle.gd
https://github.com/DigitalN8m4r3/godot-xr-tools/blob/collision_hands_demo/addons/godot-xr-tools/interactables/interactable_handle.gd


@export_group("Optional attach Hand")
## this latches the grabbing Hand onto the Interactable
##
## Requirement: Collision Hands
# Additional Note: if export paths are not set, this will be ignored
# so make sure to setup the paths corresponding to hand
# Example: left_hand_position = LeftHandMarker3D
## Requirement: Collision Hands
@export var left_hand_position : Marker3D
## Requirement: Collision Hands
@export var right_hand_position : Marker3D

# Called when the handle is picked up
func pick_up(by, with_controller) -> void:
	# Call the base-class to perform the pickup
	super(by, with_controller)
	if left_hand_position:
		if with_controller.name.matchn("*left*"):
			left_hand_position.get_node("RemoteTransform3D").remote_path = self.by_hand.get_path()
		else:
			right_hand_position.get_node("RemoteTransform3D").remote_path = self.by_hand.get_path()
	# Enable the process function while held
	set_process(true)


# Called when the handle is dropped
func let_go(_p_linear_velocity: Vector3, _p_angular_velocity: Vector3) -> void:
	# Call the base-class to perform the drop, but with no velocity
	super(Vector3.ZERO, Vector3.ZERO)
	if left_hand_position:
		left_hand_position.get_node("RemoteTransform3D").remote_path = ""
		right_hand_position.get_node("RemoteTransform3D").remote_path = ""

	# Disable the process function as no-longer held
	set_process(false)

	# Snap the handle back to the origin
	transform = Transform3D.IDENTITY

granted there are some issues but this is the fastest and it works with the current xr tools

@Malcolmnixon
Copy link
Collaborator

#559 adds support for swapping items between hands.

@Malcolmnixon
Copy link
Collaborator

This now appears to be working quite well, and we're hoping to get a release out in the next few days.

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

No branches or pull requests

3 participants