mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix gliderwield downhill run jitter
This commit is contained in:
parent
f51c4ed860
commit
400734cc0a
@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Campfires now despawn when underwater
|
- Campfires now despawn when underwater
|
||||||
- Players no longer spawn underground if their waypoint is underground
|
- Players no longer spawn underground if their waypoint is underground
|
||||||
- Map will now zoom around the cursor's position and drag correctly
|
- Map will now zoom around the cursor's position and drag correctly
|
||||||
|
- No more jittering while running down slopes with the glider out
|
||||||
|
|
||||||
## [0.10.0] - 2021-06-12
|
## [0.10.0] - 2021-06-12
|
||||||
|
|
||||||
|
@ -1231,7 +1231,7 @@ impl Client {
|
|||||||
.map(|cs| {
|
.map(|cs| {
|
||||||
matches!(
|
matches!(
|
||||||
cs,
|
cs,
|
||||||
comp::CharacterState::GlideWield | comp::CharacterState::Glide(_)
|
comp::CharacterState::GlideWield(_) | comp::CharacterState::Glide(_)
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ pub enum CharacterState {
|
|||||||
Talk,
|
Talk,
|
||||||
Sneak,
|
Sneak,
|
||||||
Glide(glide::Data),
|
Glide(glide::Data),
|
||||||
GlideWield,
|
GlideWield(glide_wield::Data),
|
||||||
/// A stunned state
|
/// A stunned state
|
||||||
Stunned(stunned::Data),
|
Stunned(stunned::Data),
|
||||||
/// A basic blocking state
|
/// A basic blocking state
|
||||||
@ -189,7 +189,7 @@ impl CharacterState {
|
|||||||
| CharacterState::Equipping(_)
|
| CharacterState::Equipping(_)
|
||||||
| CharacterState::Dance
|
| CharacterState::Dance
|
||||||
| CharacterState::Glide(_)
|
| CharacterState::Glide(_)
|
||||||
| CharacterState::GlideWield
|
| CharacterState::GlideWield(_)
|
||||||
| CharacterState::Talk
|
| CharacterState::Talk
|
||||||
| CharacterState::Roll(_),
|
| CharacterState::Roll(_),
|
||||||
)
|
)
|
||||||
@ -228,7 +228,7 @@ impl CharacterState {
|
|||||||
CharacterState::Talk => states::talk::Data.behavior(j),
|
CharacterState::Talk => states::talk::Data.behavior(j),
|
||||||
CharacterState::Climb(data) => data.behavior(j),
|
CharacterState::Climb(data) => data.behavior(j),
|
||||||
CharacterState::Glide(data) => data.behavior(j),
|
CharacterState::Glide(data) => data.behavior(j),
|
||||||
CharacterState::GlideWield => states::glide_wield::Data.behavior(j),
|
CharacterState::GlideWield(data) => data.behavior(j),
|
||||||
CharacterState::Stunned(data) => data.behavior(j),
|
CharacterState::Stunned(data) => data.behavior(j),
|
||||||
CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, j),
|
CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, j),
|
||||||
CharacterState::Dance => states::dance::Data::behavior(&states::dance::Data, j),
|
CharacterState::Dance => states::dance::Data::behavior(&states::dance::Data, j),
|
||||||
@ -264,7 +264,7 @@ impl CharacterState {
|
|||||||
CharacterState::Talk => states::talk::Data.handle_event(j, action),
|
CharacterState::Talk => states::talk::Data.handle_event(j, action),
|
||||||
CharacterState::Climb(data) => data.handle_event(j, action),
|
CharacterState::Climb(data) => data.handle_event(j, action),
|
||||||
CharacterState::Glide(data) => data.handle_event(j, action),
|
CharacterState::Glide(data) => data.handle_event(j, action),
|
||||||
CharacterState::GlideWield => states::glide_wield::Data.handle_event(j, action),
|
CharacterState::GlideWield(data) => data.handle_event(j, action),
|
||||||
CharacterState::Stunned(data) => data.handle_event(j, action),
|
CharacterState::Stunned(data) => data.handle_event(j, action),
|
||||||
CharacterState::Sit => states::sit::Data::handle_event(&states::sit::Data, j, action),
|
CharacterState::Sit => states::sit::Data::handle_event(&states::sit::Data, j, action),
|
||||||
CharacterState::Dance => {
|
CharacterState::Dance => {
|
||||||
|
@ -4,7 +4,10 @@ use crate::{
|
|||||||
fluid_dynamics::angle_of_attack, inventory::slot::EquipSlot, CharacterState, Ori,
|
fluid_dynamics::angle_of_attack, inventory::slot::EquipSlot, CharacterState, Ori,
|
||||||
StateUpdate, Vel,
|
StateUpdate, Vel,
|
||||||
},
|
},
|
||||||
states::behavior::{CharacterBehavior, JoinData},
|
states::{
|
||||||
|
behavior::{CharacterBehavior, JoinData},
|
||||||
|
glide_wield,
|
||||||
|
},
|
||||||
util::{Dir, Plane, Projection},
|
util::{Dir, Plane, Projection},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -77,8 +80,7 @@ impl CharacterBehavior for Data {
|
|||||||
if data.physics.on_ground.is_some()
|
if data.physics.on_ground.is_some()
|
||||||
&& (data.vel.0 - data.physics.ground_vel).magnitude_squared() < 2_f32.powi(2)
|
&& (data.vel.0 - data.physics.ground_vel).magnitude_squared() < 2_f32.powi(2)
|
||||||
{
|
{
|
||||||
update.character = CharacterState::GlideWield;
|
update.character = CharacterState::GlideWield(glide_wield::Data::default());
|
||||||
update.ori = update.ori.to_horizontal();
|
|
||||||
} else if data.physics.in_liquid().is_some()
|
} else if data.physics.in_liquid().is_some()
|
||||||
|| data
|
|| data
|
||||||
.inventory
|
.inventory
|
||||||
@ -86,7 +88,6 @@ impl CharacterBehavior for Data {
|
|||||||
.is_none()
|
.is_none()
|
||||||
{
|
{
|
||||||
update.character = CharacterState::Idle;
|
update.character = CharacterState::Idle;
|
||||||
update.ori = update.ori.to_horizontal();
|
|
||||||
} else if !handle_climb(data, &mut update) {
|
} else if !handle_climb(data, &mut update) {
|
||||||
let air_flow = data
|
let air_flow = data
|
||||||
.physics
|
.physics
|
||||||
@ -193,8 +194,6 @@ impl CharacterBehavior for Data {
|
|||||||
inputs_disabled,
|
inputs_disabled,
|
||||||
..*self
|
..*self
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
update.ori = update.ori.to_horizontal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update
|
update
|
||||||
@ -203,7 +202,6 @@ impl CharacterBehavior for Data {
|
|||||||
fn unwield(&self, data: &JoinData) -> StateUpdate {
|
fn unwield(&self, data: &JoinData) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
update.character = CharacterState::Idle;
|
update.character = CharacterState::Idle;
|
||||||
update.ori = update.ori.to_horizontal();
|
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,18 @@ use crate::{
|
|||||||
glide,
|
glide,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub struct Data;
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct Data {
|
||||||
|
// time since left ground, for preventing state transition
|
||||||
|
// before block snapping kicks in
|
||||||
|
timer: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Data {
|
||||||
|
fn default() -> Self { Self { timer: 0.0 } }
|
||||||
|
}
|
||||||
|
|
||||||
impl CharacterBehavior for Data {
|
impl CharacterBehavior for Data {
|
||||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||||
@ -21,7 +31,13 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
// If not on the ground while wielding glider enter gliding state
|
// If not on the ground while wielding glider enter gliding state
|
||||||
if data.physics.on_ground.is_none() {
|
if data.physics.on_ground.is_none() {
|
||||||
update.character = CharacterState::Glide(glide::Data::new(10.0, 0.6, *data.ori));
|
update.character = if self.timer > 0.3 {
|
||||||
|
CharacterState::Glide(glide::Data::new(10.0, 0.6, *data.ori))
|
||||||
|
} else {
|
||||||
|
CharacterState::GlideWield(Self {
|
||||||
|
timer: self.timer + data.dt.0,
|
||||||
|
})
|
||||||
|
};
|
||||||
}
|
}
|
||||||
if data
|
if data
|
||||||
.physics
|
.physics
|
||||||
|
@ -639,7 +639,7 @@ pub fn attempt_glide_wield(data: &JoinData<'_>, update: &mut StateUpdate) {
|
|||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
&& data.body.is_humanoid()
|
&& data.body.is_humanoid()
|
||||||
{
|
{
|
||||||
update.character = CharacterState::GlideWield;
|
update.character = CharacterState::GlideWield(glide_wield::Data::default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
flake.lock
18
flake.lock
@ -24,11 +24,11 @@
|
|||||||
"rustOverlay": "rustOverlay"
|
"rustOverlay": "rustOverlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1625378930,
|
"lastModified": 1627752074,
|
||||||
"narHash": "sha256-iBnCmrLweBmtN9VkG6AX4wSE5UUF//4VtfX6Ebhbaew=",
|
"narHash": "sha256-iuOGIbJC4hn1XqwrBjiol6j0Xj+AImND6Z9fP/6Za74=",
|
||||||
"owner": "yusdacra",
|
"owner": "yusdacra",
|
||||||
"repo": "nix-cargo-integration",
|
"repo": "nix-cargo-integration",
|
||||||
"rev": "4d6efcfd0bc6c6235b180837257ab8020f108c23",
|
"rev": "47e6414440c66bfd44a0ea07d64ca62075470f62",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -39,11 +39,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1625375231,
|
"lastModified": 1627533199,
|
||||||
"narHash": "sha256-dbp2RRftypbAYad/xhDBBG0N7s1WQW+T4jazimvtvRo=",
|
"narHash": "sha256-NyIUcNevwtsMBINn56jnDF8wz3TV1AFxw+Vw6JMnkyE=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "8aff53d3cf23b5eb67c0ba9ba2392d694ade3930",
|
"rev": "dd98b100651cfbb8804f32d852f75ef7c97a6b74",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -62,11 +62,11 @@
|
|||||||
"rustOverlay": {
|
"rustOverlay": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1625364738,
|
"lastModified": 1627697717,
|
||||||
"narHash": "sha256-TPlpEcywGnB8jNIPOlCqFVbioskGOpasrVhxdw0BHzA=",
|
"narHash": "sha256-ij7rk2VkPpNf0NTbpP5jfbwuIWfrLXN00pZ+pizGnGM=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "f08a653d9d6bbf06b5cc5dd1e570f1c449acbcf3",
|
"rev": "6d957c2105a5a548211c412fbc97bae81b7b8eb6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -291,7 +291,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
let is_gliding = matches!(
|
let is_gliding = matches!(
|
||||||
read_data.char_states.get(entity),
|
read_data.char_states.get(entity),
|
||||||
Some(CharacterState::GlideWield | CharacterState::Glide(_))
|
Some(CharacterState::GlideWield(_) | CharacterState::Glide(_))
|
||||||
) && physics_state.on_ground.is_none();
|
) && physics_state.on_ground.is_none();
|
||||||
|
|
||||||
if let Some(pid) = agent.position_pid_controller.as_mut() {
|
if let Some(pid) = agent.position_pid_controller.as_mut() {
|
||||||
|
@ -24,7 +24,7 @@ pub fn draw_char_state_group(
|
|||||||
CharacterState::Dance
|
CharacterState::Dance
|
||||||
| CharacterState::Idle
|
| CharacterState::Idle
|
||||||
| CharacterState::Sit
|
| CharacterState::Sit
|
||||||
| CharacterState::GlideWield
|
| CharacterState::GlideWield(_)
|
||||||
| CharacterState::Sneak
|
| CharacterState::Sneak
|
||||||
| CharacterState::Talk
|
| CharacterState::Talk
|
||||||
| CharacterState::Wielding => {},
|
| CharacterState::Wielding => {},
|
||||||
|
Loading…
Reference in New Issue
Block a user