WithinDistance Lineofsight Problem

Hellwalker

New member
Hello, I'm using Movement Pack and WithinDistance code. And I want to use line of sight function.

I'm having trouble understanding how it's supposed to work.

In code on line 97 we have:

Code (CSharp):

  1. if (lineOfSight.Value) {
  2. var hitTransform = MovementUtility.LineOfSight(transform, offset.Value, objects, targetOffset.Value, usePhysics2D, ignoreLayerMask.value, drawDebugRay.Value);
    [*] if (hitTransform != null) {
    [*] // the object has a magnitude less than the specified magnitude and is within sight. Set the object and return success
    [*] returnedObject.Value = objects;
    [*] return TaskStatus.Success;
    [*] }

And particularly the "if (hitTransform != null)" returns true if basically anything blocked LOS. It does not check if the returned transform is actually the target transform. So in my case Enemy Collider or a Wall can return positive on LOS.

Is this a bug, or am I doing something wrong with my setup?
For ignoreLayerMask I understood I should place here the object layers I don't want to be checked for LOS.
 
Good catch. I wonder how this hasn't come up since the release of the Movement Pack :)

If you change if(hitTransform != null) to:
Code:
                        if (hitTransform != null && MovementUtility.IsAncestor(hitTransform, targetObject.Value.transform)) {
Then it should only detect the correct objects.
 
Good catch. I wonder how this hasn't come up since the release of the Movement Pack :)

If you change if(hitTransform != null) to:
Code:
                        if (hitTransform != null && MovementUtility.IsAncestor(hitTransform, targetObject.Value.transform)) {
Then it should only detect the correct objects.
Hi there,
just a friendly reminder that this has not been updated yet.
 
Top