Raycast: getting the hit entry

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Phippu
Posts: 24
Joined: Fri Jun 03, 2011 3:39 pm

Raycast: getting the hit entry

Post by Phippu »

Hi there!

I just started playing around with bepu and I already have a little problem:-/ I used the Space.RayCast method to cast a "laser" ray. That works pretty well, but I have difficulties to determine which object has been hit. Of course there is the HitObject in the RayCastResult, but I was not able to get the entity of hit object(tried it with casting, but that didn't work). For example I've created a simple Box. How can that box get notified if it gets hit by the raycast?

Thx!!!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Raycast: getting the hit entry

Post by Norbo »

The BroadPhaseEntry that is contained by the hit information can be cast to an EntityCollidable. An EntityCollidable has an Entity property that contains the owning entity.

Architecturally, the BroadPhaseEntry and its grandchild class EntityCollidable are collision proxies. They live in the collision pipeline (broadphase, narrowphase). The entity uses the pairs and contact information found by this collision proxy to respond physically.

If you find yourself wanting to get the gameplay data associated with an object, note that the Entity has a tag property that can hold any object. Further, in the development version (http://bepuphysics.codeplex.com/SourceC ... evelopment) the BroadPhaseEntry itself has a separate tag property. Using that BroadPhaseEntry tag property can be convenient when dealing with collision events where you don't know that the objects involved are entities.
Phippu
Posts: 24
Joined: Fri Jun 03, 2011 3:39 pm

Re: Raycast: getting the hit entry

Post by Phippu »

Thank you very much, that works like a charm! I'm definitively gona have a closer look on your engine, it seems to be very fast and well supported :D
Post Reply