Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.07k stars 1.15k forks source link

ARFoundation HumanBodyTracker eventArgs.removed never called #321

Closed LangTroyan closed 5 years ago

LangTroyan commented 5 years ago

Greetings,

I'm trying to set some events when a body gets tracked or removed, playing with the method OnHumanBodiesChanged(ARHumanBodiesChangedEventArgs eventArgs) of the HumanBodyTracker script, but when the camera detects a body to track and instantiates the prefab I specified (as expected), it doesn't destroy said object when the person gets out of the camera vision. Instead it just stays floating in the scene until somebody else walks in again. I'd need it to instantiate it and destroy it when somebody walks in and out, but don't know why the .removed event never gets called. On the sample scene HumanBodyTracking3D it seems like the eventArgs never gets to the .removed state neither.

Does it need an extra configuration in order to work as I'd expect?

I've seen there's a ARHumanBody script with the Destroy On Removal parameter, but it doesn't seem to do anything.

Screenshot 2019-10-09 at 20 30 19

I really appreciate the feedback, thanks.

tdmowrer commented 5 years ago

In my experience, ARKit is quite reluctant to remove detected trackables (e.g., images), even if they are no longer visible. What is the value of ARHumanBody.trackingState when the person is no longer visible?

LangTroyan commented 5 years ago

In my experience, ARKit is quite reluctant to remove detected trackables (e.g., images), even if they are no longer visible. What is the value of ARHumanBody.trackingState when the person is no longer visible?

The ARHumanBody.trackingState is always "Tracking"

tdmowrer commented 5 years ago

The ARHumanBody.trackingState is always "Tracking"

Alright, that sounds like a bug, then. I'll fix this for the next release.

tdmowrer commented 5 years ago

Fixed in 3.0.0-preview.4

littleqiang-go commented 4 years ago

Fixed in 3.0.0-preview.4 unity2018.4 ARFoundation 1.5.0-preview fixed ?

Hypnotistas commented 4 years ago

This bug still exists in 4.1.0-preview.7. Why is that? Doesn't seem to get to eventsArg.removed part.

tdmowrer commented 4 years ago

The bug was that the tracking state was not updated correctly (which has been fixed). The behavior of eventArgs.removed is as-designed.

Hypnotistas commented 4 years ago

The bug was that the tracking state was not updated correctly (which has been fixed). The behavior of eventArgs.removed is as-designed.

As I wrote - the issue is still there, it doesn't get to "eventArgs.removed" part - if the body tracking is lost, the augmentation starts floating around it is not destroyed. Based on what was written above, tracking state has some correlation to "eventArgs.removed", correct?

So if everything works, how should the body tracking "lost" event should be accessed?

Another bug - you can't instantiate properly different outfits on runtime, it just doesn't work, I assume that's related to the same eventArgs.removed event. If the added robot prefab is not destroyed, then if we assign another outfit prefab on runtime - it is just not instantiated.

tdmowrer commented 4 years ago

Based on what was written above, tracking state has some correlation to "eventArgs.removed", correct?

No, they are separate concepts. "Removed" means ARKit has told us the anchor is gone forever. However, if it simply cannot see the human anymore, the tracking state likely will change from TrackingState.Tracking to Limited or None.

Another bug - you can't instantiate properly different outfits on runtime...

Please open a new issue for your new question, as this issue was a bug report which has been fixed and the issue is considered closed.