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

Make RayPerception sensor work better with transforms that have scale #3334

Merged
merged 2 commits into from
Feb 3, 2020

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Feb 1, 2020

Fixes #3321

Thanks @WanNJ for reporting.

This makes the Agent's transform scale behave more sensibly for raycasts; the ray length and sphere sizes are also scaled. It handles non-uniform scale reasonably, by using the length of the transforms ray to adjust these.

Also adds a few checks for division by zero.

Note that existing trained models for agents that have scale will need to be retrained, since the hit fractions will differ at runtime.

image

@@ -130,14 +130,14 @@ public void OnDrawGizmos()
// hit fraction ^2 will shift "far" hits closer to the hit color
var lerpT = rayInfo.hitFraction * rayInfo.hitFraction;
var color = Color.Lerp(rayHitColor, rayMissColor, lerpT);
color.a = alpha;
color.a *= alpha;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran into this when trying to get a screenshot; I wanted to hide the "higher" raycast component by setting its alpha to 0

@chriselion chriselion changed the title Develop raycast scale Make RayPerception sensor work better with transforms that have scale Feb 3, 2020
@chriselion chriselion merged commit 30a8926 into master Feb 3, 2020
@delete-merged-branch delete-merged-branch bot deleted the develop-raycast-scale branch February 3, 2020 20:45
chriselion pushed a commit that referenced this pull request Feb 3, 2020
chriselion pushed a commit that referenced this pull request Feb 3, 2020
* Migration guide for RayPerceptionSensor+scale

Followup from #3334

* whitespace
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RayPerceptionSensorComponent3D does not function as expected when the agent's scale is not 1.
2 participants