public void DetectGround() { _groundHitInfo = new GroundHit { groundPoint = transform.position, groundNormal = transform.up, surfaceNormal = transform.up }; ComputeGroundHit(transform.position, transform.rotation, ref _groundHitInfo, castDistance); }
private void FixedUpdate() { _groundHitInfo = new GroundHit { groundPoint = transform.position, groundNormal = transform.up, surfaceNormal = transform.up }; ComputeGroundHit(transform.position, transform.rotation, ref _groundHitInfo, castDistance); text.text = isOnGround.ToString(); }
public bool ComputeGroundHit(Vector3 position, Quaternion rotation, ref GroundHit groundHitInfo, float distance = Mathf.Infinity) { RaycastHit hitInfo; if (BottomSphereCast(position, rotation, out hitInfo, distance) && Vector3.Angle(hitInfo.normal, rotation * Vector3.up) < 89.0f) { groundHitInfo.SetFrom(hitInfo); groundHitInfo.surfaceNormal = hitInfo.normal; groundHitInfo.isOnGround = true; return(true); } else { return(false); } }