shapecast for camera pos
This commit is contained in:
@@ -140,11 +140,15 @@ fn update(
|
||||
let max_distance = camera.distance;
|
||||
|
||||
let filter = SpatialQueryFilter::from_mask(LayerMask(GameLayer::Level.to_bits()));
|
||||
let cam_pos = if let Some(first_hit) =
|
||||
spatial_query.cast_ray(target, direction, max_distance, false, &filter)
|
||||
{
|
||||
//TODO: maybe shape casting a sphere would be better
|
||||
let distance = first_hit.distance * 0.9;
|
||||
let cam_pos = if let Some(first_hit) = spatial_query.cast_shape(
|
||||
&Collider::sphere(0.5),
|
||||
target,
|
||||
Quat::IDENTITY,
|
||||
direction,
|
||||
&ShapeCastConfig::from_max_distance(max_distance),
|
||||
&filter,
|
||||
) {
|
||||
let distance = first_hit.distance;
|
||||
target + (direction * distance)
|
||||
} else {
|
||||
target + (direction * camera.distance)
|
||||
|
||||
Reference in New Issue
Block a user