Im creating a characterphysics in unity using raycast, but im not getting the correct value from raycasting on a flat surface, the value should be = (0.0, 1.0) but it is (1.0, 0.0)
anyone have experiences similiar problem?
Code
hit = Physics2D.Raycast(new Vector2(x, y), velocity.normalized, velocity.magnitude+skin);
if (Physics2D.Raycast(new Vector2(x, y), velocity.normalized, velocity.magnitude+skin ))
{
if (i == 0 && 0.3f < hit.normal.y)
{
direction = Vector3.Cross(hit.normal, hit.collider.transform.forward);
newdir = direction * deltaX;
}
else
{
if (grounded && 0 >= hit.normal.y)
{
Debug.Log("Land " + hit.normal + " " + velocity.normalized);
playerController.currentSpeed = 0;
}
newdir = new Vector2(0, deltaY);
}
hited = true;
}
}