However, when I do a ray cast in the direction of the tree. It cannot detect it, and simply returns no collisions from the ray cast result.
Code: Select all
public void rayCast(Vector3 position, Vector3 direction, float distance)
{
List<RayCastResult> rayCastResults = new List<RayCastResult>();
if (space.RayCast(new Ray(position, direction), distance, RayCastFilter, rayCastResults))
{
var entityCollision = rayCastResults[0].HitObject as EntityCollidable;
if (entityCollision != null)
{
//DebugDisplay.update("0", entityCollision.Entity.Tag.ToString()); found it print
}
if (rayCastResults.Count > 1)
{
var entityCollision2 = rayCastResults[1].HitObject as EntityCollidable;
if (entityCollision2 != null)
{
DebugDisplay.update("1", entityCollision2.Entity.Tag.ToString()); found it print. Just to make sure there isn't multiple.
}
}
}
else
{
//DebugDisplay.update("SEESOMETHING", "I CANNOT SEE ANYTHING"); Not found anything.
}
}
bool RayCastFilter(BroadPhaseEntry entry)
{
return entry != Game.getGV().Body.CollisionInformation && entry.CollisionRules.Personal <= CollisionRule.Normal;
}
However, when the same is done for detecting a DynamicObject which is a ConvexHull created from a virus shaped model. It finds it and prints to say it is found as shown in the if above.
How come it is not detecting the StaticMesh?
*EDIT* Ok it seems to have just started detecting it. Don't know what was going on before!