私のゲーム ワールドの誰もが、センサー シェイプが取り付けられたフィクスチャを持っています。レイキャストすると、これらのフィクスチャにヒットしますが、少なくとも 1 つの形状がセンサーではないフィクスチャにのみヒットしたいと考えています。これは可能ですか?
Box2dx - C# ポートを使用しています。
また、コールバックは何をしますか?
world.PhysicsWorld.RayCast((f, p, n, fr) =>
{
fixture = f;
position = p;
return fr;
}, point1, point2);
これは、私が呼び出しているレイキャスト関数です。ドキュメントには、コールバックを使用して取得する形状の数を指定できると書かれていますが、その方法がわかりません。
/// Ray-cast the world for all fixtures in the path of the ray. Your callback
/// controls whether you get the closest point, any point, or n-points.
/// The ray-cast ignores shapes that contain the starting point.
/// @param callback a user implemented callback class.
/// @param point1 the ray starting point
/// @param point2 the ray ending point
public void RayCast(Func<Fixture, Vector2, Vector2, float, float> callback, Vector2 point1, Vector2 point2)
{
RayCastInput input = new RayCastInput();
input.maxFraction = 1.0f;
input.p1 = point1;
input.p2 = point2;
_rayCastCallback = callback;
_contactManager._broadPhase.RayCast(_rayCastCallbackWrapper, ref input);
_rayCastCallback = null;
}