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

AngularDrives not raising TargetValueReached event #78

Open
NilsBernatzki opened this issue Nov 10, 2020 · 10 comments
Open

AngularDrives not raising TargetValueReached event #78

NilsBernatzki opened this issue Nov 10, 2020 · 10 comments
Labels
bug Something isn't working

Comments

@NilsBernatzki
Copy link

NilsBernatzki commented Nov 10, 2020

Environment

Unity 2020.1
Tilia Controllables 1.10.13

Issue:

The TargetValueReached UnityEvent won't get raised on an AngularJoint/TransformDrive when the TargetValue is set by code.

Reproduce:

  1. Place an Interactions.AngularJointDrive prefab in the scene.

  2. Hook the public SetTargetValueByStepValue() function in the Facades StepValueChanged UnityEvent.

  3. Enable/Disable the Drives public MoveToTargetValue property in the Ungrabbed/Grabbed UnityEvents in the Interactable.

  4. Call a Debug function from the TargetValueReached UnityEvent of the Drive.

  5. Move the Drive around by grabbing it with an Interactor and notice the TargetValueReached event not being raised, even if the Drive obviously reaches its target value.

  6. Do same with LinearJointDrive prefab.

  7. Notice TargetValueReached event is getting raised properly on the linear drive.

Greetings!

@NilsBernatzki NilsBernatzki changed the title AngularJointDrive not overriding SetDriveTargetValue() AngularDrives not raising TargetValueReached event Nov 10, 2020
@NilsBernatzki
Copy link
Author

I noticed that the virtual function SetDriveTargetValue() is only overridden in the LinearTransform/JointDrive scripts while the angular once don't.

@extendreality extendreality added the bug Something isn't working label Nov 11, 2020
@extendreality
Copy link
Contributor

I've tried recreating this in Unity 2018.3.14f and I cannot recreate the issue. I get the Target Value Reached every time

@NilsBernatzki
Copy link
Author

NilsBernatzki commented Nov 12, 2020

Reproduced issue today with described setup:

AngularDriveFacade
image

Debug function just loggs some text in the console.

The InteractableFacade used in the Drive
image

  1. Once the object is grabbed and rotated and Value reaches a StepValue, the TargetValue gets updated correctly
  2. If I release the Grab the Drive rotates towards the current StepValue, because it was set as the TargetValue, what is also as expected
  3. Once the Drive stopps moving, because it reaches the TargetValue, the TargetValueReached event is NOT being raised.

I can only make the TargetValueReached event get raised if I set the TagetValue by hand in the inspector in runtime.

What additional information could be helpful?

@NilsBernatzki
Copy link
Author

Found the problem!

Once the object is Ungrabbed and the Difference of the TagetValue and the current Value is already lower than the TargetValueReachedThreshold of the AngularJointDrive the event is not being raised.

Once the TargetValueReachedThreshold was lowered to a very small value (I used 0.0025f), the event was raised as it should.

@thestonefox
Copy link
Member

That should be your solution then, if your precision is so small that the threshold is too large then lowing the threshold is the correct approach

@NilsBernatzki
Copy link
Author

Is that behaviour intended? I mean, I would also expect the TargetValueReachedEvent to get raised when the Ungrab occurs and the difference to the TargetValue is already lower than the threshold.

Even if it fixes it for me, I see a problem with higher DriveSpeed values with this approach. A very low TargetValueReachedThreshold can cause the Drive to hop between a value higher/lower than TargetValue +/- TargetValueReachedThreshold and never reach the desired range that raise the event.

@thestonefox
Copy link
Member

You need to provide better steps to recreate the issue then, because I followed your original steps and could not recreate the issue you are talking about

@NilsBernatzki
Copy link
Author

As you already said:

...lowing the threshold is the correct approach

and I just wanted to know if the behaviour I described is intented. If it is not, what do yo mean with "better" ? I have already asked what additional information could be helpful to make things clearer.

@thestonefox
Copy link
Member

As you already said:

...lowing the threshold is the correct approach

and I just wanted to know if the behaviour I described is intented. If it is not, what do yo mean with "better" ? I have already asked what additional information could be helpful to make things clearer.

The original steps outlined in this issue ticket do not reproduce the problem that has been mentioned. So it is not certain to know if there is a bug or not.

I have followed the 7 steps exactly and the bug does not occur. So there must be some missing step or configuration to cause the issue that you are seeing. If you can recreate the problem with the exact steps then I can attempt to recreate it and confirm if there is in fact any issue.

@NilsBernatzki
Copy link
Author

Updated to Tilia Interactions Controllables Unity 1.10.14
Unity 2020.1.2f1
URP

  1. I created a new scene with only the fundamental contents for VR and to grab the Drive
    a. CameraRigs.UnityXR prefab
    b. CameraRigs.TrackedAlias
    c. Wrapper Actions for SteamVR Input system (noticed Tilia also offers prefabs, but still had no motivation to swap to yours)
    d. Interactors for left/right controller representation with an input action referenced to perform the Grab (I used a boolean proxy with the Grip Button as its source) and small cubes for visual representation and collision
    c. A debug script somewhere in the scene with a public function that loggs into the console

image

  1. I added an Interactions.AngularJointDrive prefab to the scene and moved it somewhere close to the cameraRigs position, so I can reach it from the start.

My goal is to use the StepValue as the new TargetValue, everytime a StepValue changes as I rotate the drive around. Once I ungrab the drive, it should automatically rotate towards the StepValue.

To achieve that I did the following:

a. I referenced the SetTargetValueByStepValue function of the AngularDriveFacade inside the StepValueChanged UnityEvent of the same AngularDriveFacade in the inspector and left everything else as it is

image

When I hit play , grab the drive and rotate it around, I can see the TargetValue changes as expected, once a StepValue changed.

b. To make the Drive rotate towards its new TargetValue, MoveToTargetValue needs to be active, but only if I dont't grab the drive. So I set MoveToTargetValue to false/true once I grab/ungrab the Interactable of the Drive, by using the appropriate Unity Events of the InteractableFacade inside the Drive

image

When I hit play, grab the drive, rotate it around and release the grab, I can see the Drive rotateing towards the current TargetValue automatically.

  1. I referenced my debug logger scripts public function in the TargetValueReached Unity Event of the AngularDriveFacade to log some text into the console, once the event is being raised.

This is how my AngularDriveFacade looks like right now:

image

This is the Internal AngularJointDrive. It's Moment is processed in FixedUpdate and also no changes made in the component itself:

image

And the InteractableFacade :

image
image

When I hit play, grab the Drive, rotate it around, ungrab it and wait for it to reach its TargetValue, there is NO reaction in the console.

  1. I set the TargetValueReachedThreshold to a smaller value (I used 0.0025f in this case)

image

When I hit play, grab the Drive, rotate it around, ungrab it and wait for it to reach its TargetValue, there is the expected reaction in the console.

image

Here are my Physics Settings of the project:

image
image

I really don't how to better explain the steps I do to recreate this issue for me. All the other components of the Drive prefab haven't been touched.

If there is something I missed that could be helpful, please let me now.

Thx

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

No branches or pull requests

3 participants