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