I am trying to set up "my own collision engine" by using Unity logic just as helpers. I have two distinct game objects, they are both set up with components:
- BoxCollider2D (Is Trigger)
- Rigidbody 2D (Dynamic, simulated, discrete, start awake)
I was under the impression that if I were to run BoxCollider2D.Cast, passing the default layer they are both in, I would get the other object in the list of hits. However the list of hits always just returns the floor object (which has the PlatformEffector2D component).
Isnt the point of Cast to return other GameObjects?
Small Snippet where the problem is going on:
```csharp
private bool Move(Vector2 directionAxis, float force, out RaycastHit2D hit)
{
hit = default;
Vector2 dir = force > 0 ? directionAxis : directionAxis * -1f;
float dist = Mathf.Abs(force);
int count = col.Cast(dir, filter, hits, dist + SKIN_WIDTH);
if (count > 0)
{
hit = hits[0];
transform.position += (Vector3)(dir * (hit.distance - SKIN_WIDTH));
return true;
}
transform.position += (Vector3)directionAxis * force;
return false;
}
public bool MoveHorizontal(float forceX, out RaycastHit2D hit)
{
return Move(Vector2.right, forceX, out hit);
}
