Vrtk: Scene 021 - Door Doesn't Behave as Expected

Created on 12 May 2016  路  23Comments  路  Source: ExtendRealityLtd/VRTK

021_Controller_GrabbingObjectsWithJoints

It appears (to me at least on my end) that the door's physics response to being grabbed and opened/closed is _multiplied_ the further you move the controller from the initial grab point. The small container though (with the marbles) behaves as expected.

Fantastic job btw, bravo! :+1:

Cheers

-Steven

bug

All 23 comments

The spring joint when moved too far away from an object causes the physics engine to go haywire because it doesn't know which joint to resolve to.

Possible solution is to break the spring joint when the controller moves a given distance from the object.

I'll look to implement a fix like this.

I guess it's curious why the small box with the hinged lid works fine, but the door does not. It's not as if I'm doing any more than 'simulating' opening the door by is handle as one naturally would. (see my other post regarding janky physics)

This clearly seems like a bug as I can grab the door by the knob, and upon even _slightly_ moving it, the door begins to misbehave greatly.

Are you not seeing this in your latest file?

The door works ok for me, except when i move the controller too far away from it, then it goes weird

you do get the same issue with the box handle too, if you pull the controller too far, you can see the joint detach from the box lid.

The difference with the door is it's one big hinge joint, and hinge joints in unity seem a bit crazy.

Hmmm well if I grab the door close to the hinge, it behaves a little better. But grabbing the door by it's knob refuses to work correctly.

Again the disparity between what we're experiencing is disconcerting. They should be largely the same as these are unaltered files from your depot.

Possible that both _filtering_ of the movement to accommodate the hinged object (favor the object rather than hand position for smoothing) and couple that with that limiter i mentioned in my other issue, where if the hand moves away from the object by _X_, the grab is disengaged?

What version of Unity are you using? I'm on 5.3.41f

Wondering if it's a difference between versions?

Same version (64 bit)...

...I'm so tempted to install the Beta but I know how that ends up typically.

I'll have a play around with it my end and see if I can get it to act crazy too.

Perhaps this might help

You can see in his video it's quite fluid, and if it's even a _small approximation_ of Amnesia then he's in good company.

Dragging rigidbodies with the mouse is fortunately a often-asked and well-documented feature in the Unity community, so much so it's even included in Adventure Creator. Might offer some additional help

Moving rigidbodies around by pushing a rigid body via code means the physics engine has chance to solve collisions in the update routine meaning blocks can never collide.

Because the objects are attached to the controller (which has no rigidbody) means you can push it into objects and the attached object doesn't know how to cope with not being able to enter.

I have a fix for the items going crazy, just snap to joint if it can't resolve the collision.

I wonder if rigidbodies on the controller objects would prevent them going into items too.

Technically a fix for this issue, but also for preventing grabbed objects from going crazy when the controller tries to pull them into other objects.

Also, snaps the spring joint on the controller if it gets too far away from the grabbed object.

Fixed in commit: 4c0823ccf085a01c05917a89f25a007ddefeec68

Also, video to demonstrate how it's working on my machine (to show I'm not crazy or just lying to you all!!! :P)
https://www.youtube.com/watch?v=c-dvkJu9Dlo

Yours does it too actually. Watch from :24 - :28...it looks like you're pulling on the door with a rubber band attached to the doorknob. Interacting with hinged/jointed objects in VR is quite common (i.e. The Lab, Job Simulator, The Gallery, Hover Junkers) all of those which work quite well and behave as one would expect (1:1 with controller movement). Out of Ammo has a mounted machine gun that requires you hold both handles to operate and fire which is quite fancy. :)

Not certain how to approach this but I'd argue the task should be reopened.

Cheers

-Steven

The reason it looks as if a rubber band is holding it is because that's how it's effectively working.

A spring joint is attached to the door so you can pull it with a joint that has a variable length to prevent physics from going crazy.

Job Simulator (and other games) hide the visual issues by hiding the controller, but also they may not be using joints to grab this kind of object. They may be tracking the grabbed object to the controller (via changing it's position and rotation in code) this is how NewtonVR does it. This way handles this kind of grabbing better but sucks for grabbing objects that track to the controller (e.g. their gun model) because the object is always playing catch up with the controller.

I can play with using a configurable joint instead of a spring joint and see what results that achieves. But it may be that using joints to open doors isn't the best way and a separate script may be required that tracks the hand instead, then instead of grabbing doors, you'd use a door and have a door script that inherits the Interact_Use script and deals with it without joints.

I think joints works the best way for grabbing/picking up objects, it even works quite well for the drawer and box, but I think it's probably never going to be perfect for doors.

Well even if this is now just for discussion, how would you compare this then to games like Amnesia? The YouTube link I sent you yesterday has Rigidbody objects and doors that track the mouse quite accurately, and the only real difference here is that we have an additional axis that honestly may not even be a factor.

I think the most compelling argument for accurate joint tracking is the lamp in The Lab. It's a multi-joint object with limits, and it tracks beautifully 1:1.

I won't keep pushing this as you're right it isn't crucial, but perhaps at some point when you're rounding out your already robust toolset, you might want to come back to it. :)

(P.S. Ever consider dropping this on the Asset Store, monetizing it? Even if you want to keep it Open Source, you might garner additional support and help from the community)

Cheers Stone!

-Steven

The difference with Amnesia is you're controlling one rigidbody with another.

The problem here is using a joint from an object (that isn't a rigidbody [but thats not the main problem]) to connect to another object that has a joint.

I fully expect the lab isn't using a joint on the controller object to attach to the slingshot or lamp.

The lamp and slingshot have joints that move them but the object you interact with just tracks the movement of the controller it isn't attached implicitly to the controller.

It's exactly how NewtonVR do it and it works really well for this scenario.

My thoughts on it are, this example scene showing how to do it with "grabbable" objects is probably as good as I can get it (because grabbing an object is best done with joints imho)...unless there is a Unity guru out there that can replace the Spring Joint with an awesome Configurable Joint!

But my plan to move forward isn't to try and implement 1:1 control on fixed objects by using the grab mechanic, it's to do it via a different way using the "Use" mechanic then use controller tracking like NewtonVR.

Grabbing is when you want to hold something in your hand and carry it around and it tracks your hand perfectly, which is what happens now, if you pick a cube up, no matter how much you swing your controller, it's perfectly mapped to it.

NewtonVR and the Lab both show that if you swing your controller crazily then the item always plays catchup (in the lab grabbed items track so I bet they do it in 2 different ways too).

I don't think there is a one solution fits all here, so next is to do an example of showing how objects with joints can be manipulated using the "Using" part of the interactable object.

I'll model a lamp, a door and that sort of stuff to show it working.

Lamp will just be a bunch of character joints I'm guessing :)

I'll create a new issue to track the progress, because I think this issue is in regards to using the grab mechanic.

FYI: https://github.com/thestonefox/SteamVR_Unity_Toolkit/issues/54

You know I completely agree actually, and now you have me curious to explore additional tracking options now that you've laid this foundation.

Onwards to 54!!

Cheers brother

-Steven

I may even take out this grabbing spring joint stuff if the other way works better. I can see it being problematic. Like if you want to pick a case up with a hinge then it won't work properly. I think using items with hinges is a different thing to picking items up

AH! You just reminded me of another issue (and it might be this one actually)...

...but if you place a cube on top of another cube (sticking with your scene mind you, so of course any object on top of any other object as well), if you attempt to pick up the _'bottom'_ object, with the aim of balancing the _'top'_ object on it's surface, the top object falls down and away from the _held_ bottom object.

Job Simulator has you placing several objects on top of plates for example, and then you grab the plate to move all of the items together, elsewhere.

@thestonefox

I'll model a lamp, a door and that sort of stuff to show it working.

Here's my time to shine. I put together a basic scene with a table, lamp, and doors. Didn't import it into Unity yet, but it should all be fine more or less. Maybe I can iterate on this scene and help you make a little test space.

image preview, toolkit_geometry_v001

fbx file here, https://www.dropbox.com/s/o9rkyfhzizl8d78/Toolkit_Geometry_v001.FBX?dl=0

@xEvoGx ahh I know why that is. There's a piece of code that disables collisions for a second or so when you grab something so you don't stick it inside another object and then lose it whilst it does the snapping.

I could make an option to toggle that as it may not always be required.

@bcoyle Those models look awesome! Thanks for the work!

@xEvoGx Check out the latest commit: 694227f478f30379411ace3d977b23ccdf47b068

you can now set a toggle on an interactable object to whether it pauses collisions on grab.

It still may be desireable to pause collisions in some instances.

Sweet! I'm on it after lunch!

@xEvoGx check out this branch if you get chance

https://github.com/thestonefox/SteamVR_Unity_Toolkit/tree/feat/hinged-object-interaction

Needs work on it still but it's a proof of concept in controlling jointed objects via a tracking method instead of a fixed joint method.

The drawer still doesn't work, but the box and door now use this new tracking method, they're pretty close to 1:1. Let me know what you think.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dantman picture dantman  路  4Comments

thestonefox picture thestonefox  路  5Comments

dantman picture dantman  路  6Comments

xEvoGx picture xEvoGx  路  5Comments

cameronoltmann picture cameronoltmann  路  6Comments