mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better tethering physics
This commit is contained in:
parent
5a41d7e33e
commit
a01739af20
@ -150,7 +150,7 @@ impl Body {
|
||||
quadruped_low::Species::Driggle => 120.0,
|
||||
quadruped_low::Species::HermitAlligator => 120.0,
|
||||
},
|
||||
Body::Ship(ship::Body::Carriage) => 200.0,
|
||||
Body::Ship(ship::Body::Carriage) => 35.0,
|
||||
Body::Ship(_) => 0.0,
|
||||
Body::Arthropod(arthropod) => match arthropod.species {
|
||||
arthropod::Species::Tarantula => 135.0,
|
||||
|
@ -901,6 +901,7 @@ impl<'a> PhysicsData<'a> {
|
||||
.try_normalized()
|
||||
.and_then(|dir| Some(orientations.get(entity)?.right().dot(dir).abs()))
|
||||
.unwrap_or(1.0)
|
||||
.max(0.2)
|
||||
} else {
|
||||
1.0
|
||||
},
|
||||
@ -945,6 +946,7 @@ impl<'a> PhysicsData<'a> {
|
||||
.try_normalized()
|
||||
.and_then(|dir| Some(1.0 - orientations.get(entity)?.right().dot(dir).abs()))
|
||||
.unwrap_or(1.0)
|
||||
.max(0.2)
|
||||
} else {
|
||||
1.0
|
||||
},
|
||||
@ -1241,6 +1243,7 @@ impl<'a> PhysicsData<'a> {
|
||||
.try_normalized()
|
||||
.and_then(|dir| Some(1.0 - orientations.get(entity)?.right().dot(dir).abs()))
|
||||
.unwrap_or(1.0)
|
||||
.max(0.2)
|
||||
} else {
|
||||
1.0
|
||||
},
|
||||
|
@ -79,8 +79,7 @@ impl<'a> System<'a> for Sys {
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let tether_pos = follower_pos.0 + tether_offset;
|
||||
let pull_factor = ((leader_pos.0.distance(tether_pos) - is_follower.tether_length)
|
||||
* 0.5)
|
||||
let pull_factor = (leader_pos.0.distance(tether_pos) - is_follower.tether_length)
|
||||
.clamp(0.0, 1.0)
|
||||
.powf(2.0);
|
||||
let strength = pull_factor * 50000.0;
|
||||
@ -94,11 +93,9 @@ impl<'a> System<'a> for Sys {
|
||||
velocities.get_mut(leader).unwrap().0 -= impulse / leader_mass.0;
|
||||
|
||||
if let Some(follower_ori) = orientations.get_mut(follower) {
|
||||
let turn_strength = pull_factor
|
||||
* follower_body
|
||||
.map(|b| b.tether_offset().magnitude())
|
||||
.unwrap_or(0.0)
|
||||
* 4.0;
|
||||
let turn_strength = pull_factor.min(0.2)
|
||||
// * (tether_offset.magnitude() - tether_offset.dot(pull_dir).abs())
|
||||
* 50.0;
|
||||
let target_ori = follower_ori.yawed_towards(Dir::new(pull_dir));
|
||||
*follower_ori = follower_ori.slerped_towards(target_ori, turn_strength * dt.0);
|
||||
}
|
||||
|
@ -1630,7 +1630,7 @@ fn handle_spawn(
|
||||
.link(Tethered {
|
||||
leader,
|
||||
follower,
|
||||
tether_length: 3.0,
|
||||
tether_length: 4.0,
|
||||
})
|
||||
.map_err(|_| "Failed to tether entities")?;
|
||||
} else {
|
||||
@ -1824,7 +1824,7 @@ fn handle_spawn_ship(
|
||||
.link(Tethered {
|
||||
leader,
|
||||
follower,
|
||||
tether_length: 3.0,
|
||||
tether_length: 4.0,
|
||||
})
|
||||
.map_err(|_| "Failed to tether entities")?;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user