3
我的遊戲世界中的每個人都有附加傳感器形狀的燈具。當我進行光線投射時,它會擊中這些燈具,但我只想用至少一個不是傳感器的形狀擊中燈具。這可能嗎?Box2dx:指定要在光線投射中忽略的燈具?
我正在使用Box2dx - C#端口。
此外,回調是做什麼的?
world.PhysicsWorld.RayCast((f, p, n, fr) =>
{
fixture = f;
position = p;
return fr;
}, point1, point2);
這是我打來的raycast函數。該文件說,回調可用於指定形狀的數量回去,但我不知道該怎麼做:
/// 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;
}