Page 1 of 1
Collision Rules for RayCast only
Posted: Fri May 20, 2011 2:13 pm
by m.starkov
Hi,
Could one please advise on the following questions?
Is it possible to set some collision rule for a body to exclude it from any physics calculations except participating in the Ray Cast checks?
It is needed in case if we are not interested in checking collisions between some multiple objects however we need to know if they are there by the ray casting (may be it will be decided to set body back to collisions arena).
Here I would like also to ask is it possible to get a particular entity by the ray cast (not just abstract broad phase entity returned by Space.RayCast)?
Re: Collision Rules for RayCast only
Posted: Fri May 20, 2011 8:48 pm
by Norbo
Is it possible to set some collision rule for a body to exclude it from any physics calculations except participating in the Ray Cast checks?
You could set its entity.CollisionInformation.CollisionRules.Personal = CollisionRules.NoBroadPhase. It will still live in the broad phase, but it won't produce broad phase overlaps to be consumed by later stages. This means you can still query it with ray casts. Other collision rule setups will work fine too.
Collision rules do not affect ray casting unless you choose to filter for it (using the Space.RayCast overloads or otherwise).
Here I would like also to ask is it possible to get a particular entity by the ray cast (not just abstract broad phase entity returned by Space.RayCast)?
You can test to see if the BroadPhaseEntry is actually an EntityCollidable (which is a subclass of BroadPhaseEntry). If it is, you can check its Entity property. If you just need a tag, note that the BroadPhaseEntry has a tag property.
Re: Collision Rules for RayCast only
Posted: Sat May 21, 2011 12:21 am
by m.starkov
Hi Norbo,
Thanks for your answer. I was suggesting the same but BroadPhaseEntry name confused me to thinking that it might be not available because broad phase is disabled for the entity. It is nice to hear that it is not so.
>> the BroadPhaseEntry is actually an EntityCollidable ... If you just need a tag, note that the BroadPhaseEntry has a tag property.
Yes it has, but it seems to be that it does not take entity's tag. I'm not sure how could I get the entity tag from BroadPhaseEntry...
Re: Collision Rules for RayCast only
Posted: Sat May 21, 2011 12:55 am
by Norbo
The easiest thing to do is just to set the CollisionInformation's tag to whatever you would have put in the Entity's tag. You could also put the entity into the tag, but that ends up being similar to just casting to EntityCollidable and using the entity property.