Skip to content

Commit

Permalink
Using lossy scale instead of local scale
Browse files Browse the repository at this point in the history
  • Loading branch information
DerKekser committed Jun 23, 2024
1 parent fb9c406 commit b62b0e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Assets/Kekser/Sensors/RaySensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override Collider[] GetComponentsInSensor()
{
RaycastHit[] hits = Physics.RaycastAll(
transform.position,
Vector3.Scale(transform.forward, transform.localScale).normalized,
Vector3.Scale(transform.forward, transform.lossyScale).normalized,
_distance,
_scanLayer,
QueryTriggerInteraction.Ignore);
Expand All @@ -33,7 +33,7 @@ protected override Collider[] GetComponentsInSensor()
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
Gizmos.DrawRay(transform.position, Vector3.Scale(transform.forward, transform.localScale).normalized * _distance);
Gizmos.DrawRay(transform.position, Vector3.Scale(transform.forward, transform.lossyScale).normalized * _distance);
}
}
}
4 changes: 2 additions & 2 deletions Assets/Kekser/Sensors/RaySensor2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override Collider2D[] GetComponentsInSensor()
{
RaycastHit2D[] hits = Physics2D.RaycastAll(
transform.position,
Vector3.Scale(transform.right, transform.localScale).normalized,
Vector3.Scale(transform.right, transform.lossyScale).normalized,
_distance,
_scanLayer);

Expand All @@ -32,7 +32,7 @@ protected override Collider2D[] GetComponentsInSensor()
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
Gizmos.DrawRay(transform.position, Vector3.Scale(transform.right, transform.localScale).normalized * _distance);
Gizmos.DrawRay(transform.position, Vector3.Scale(transform.right, transform.lossyScale).normalized * _distance);
}
}
}
4 changes: 2 additions & 2 deletions Assets/Kekser/Sensors/ViewSensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override Collider[] GetComponentsInSensor()

for (int i = hitObjects.Count - 1; i >= 0; i--)
{
if (Vector3.Angle(hitObjects[i].transform.position - transform.position, Vector3.Scale(transform.forward, transform.localScale).normalized) > _angle / 2f)
if (Vector3.Angle(hitObjects[i].transform.position - transform.position, Vector3.Scale(transform.forward, transform.lossyScale).normalized) > _angle / 2f)
hitObjects.RemoveAt(i);
}

Expand All @@ -31,7 +31,7 @@ protected override Collider[] GetComponentsInSensor()
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
SensorGizmos.DrawWireView(transform.position, Vector3.Scale(transform.forward, transform.localScale).normalized, _range, _angle);
SensorGizmos.DrawWireView(transform.position, Vector3.Scale(transform.forward, transform.lossyScale).normalized, _range, _angle);
}
}
}
4 changes: 2 additions & 2 deletions Assets/Kekser/Sensors/ViewSensor2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override Collider2D[] GetComponentsInSensor()

for (int i = hitObjects.Count - 1; i >= 0; i--)
{
if (Vector2.Angle(hitObjects[i].transform.position - transform.position, Vector3.Scale(transform.right, transform.localScale).normalized) > _angle / 2f)
if (Vector2.Angle(hitObjects[i].transform.position - transform.position, Vector3.Scale(transform.right, transform.lossyScale).normalized) > _angle / 2f)
hitObjects.RemoveAt(i);
}

Expand All @@ -31,7 +31,7 @@ protected override Collider2D[] GetComponentsInSensor()
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.yellow;
SensorGizmos.DrawWireView(transform.position, Vector3.Scale(transform.right, transform.localScale).normalized, _range, _angle);
SensorGizmos.DrawWireView(transform.position, Vector3.Scale(transform.right, transform.lossyScale).normalized, _range, _angle);
}
}
}
2 changes: 1 addition & 1 deletion Assets/Kekser/Sensors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.kekser.sensors",
"displayName": "Sensors",
"author": { "name": "Kekser", "url": "https://github.com/DerKekser" },
"version": "1.1.0",
"version": "1.1.1",
"unity": "2020.3",
"description": "A Sensor system for Unity",
"keywords": [ "sensor", "sensors", "visibility" ],
Expand Down

0 comments on commit b62b0e5

Please sign in to comment.