Hi,
Here is my code:
protected override void OnUpdate()
{
_collisionWorld = _physics.PhysicsWorld.CollisionWorld;
Entities.ForEach((ref GroundCollide collide, ref Translation position) =>
{
RaycastInput input = new RaycastInput()
{
Start = position.Value,
End = position.Value - math.up(),
Filter = new CollisionFilter()
{
BelongsTo = ~0u,
CollidesWith = ~0u,
GroupIndex = 0
}
};
RaycastHit hit = new RaycastHit();
bool haveHit = _collisionWorld.CastRay(input, out hit);
if (haveHit)
{
var posi = hit.Position;
var distance = math.distance(posi, position.Value);
LoggerSystem.Log(posi + " << point... origin >> " + position.Value);
// if (distance >= 1.01)
// {
// collide.IsGrounded = false;
// }
// else
// {
// collide.IsGrounded = true;
// }
collide.IsGrounded = true;
}
});
}
I want to build a simple “isGrounded” system, but position.Value is always printing the origin of the ray??
eg posi == position.Value;
What is wrong with my code?