mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'zesterer/better-rollin' into 'master'
Made rolling less slippy, added tilt See merge request veloren/veloren!699
This commit is contained in:
commit
423e741cb6
@ -1,7 +1,8 @@
|
|||||||
use super::phys::GRAVITY;
|
use super::phys::GRAVITY;
|
||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{
|
||||||
CharacterState, Controller, Mounting, MovementState::*, Ori, PhysicsState, Pos, Stats, Vel,
|
ActionState, CharacterState, Controller, Mounting, MovementState::*, Ori, PhysicsState,
|
||||||
|
Pos, Stats, Vel,
|
||||||
},
|
},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, ServerEvent},
|
||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
@ -180,7 +181,12 @@ impl<'a> System<'a> for Sys {
|
|||||||
// producing potentially unexpected changes in direction
|
// producing potentially unexpected changes in direction
|
||||||
Vec2::from(vel.0)
|
Vec2::from(vel.0)
|
||||||
} else {
|
} else {
|
||||||
Vec2::from(inputs.move_dir)
|
if let ActionState::Roll { .. } = character.action {
|
||||||
|
// So can can't spin/slip around while rolling
|
||||||
|
Vec2::from(vel.0)
|
||||||
|
} else {
|
||||||
|
Vec2::from(inputs.move_dir)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ori_dir.magnitude_squared() > 0.0001
|
if ori_dir.magnitude_squared() > 0.0001
|
||||||
|
@ -10,11 +10,11 @@ pub struct RollAnimation;
|
|||||||
|
|
||||||
impl Animation for RollAnimation {
|
impl Animation for RollAnimation {
|
||||||
type Skeleton = CharacterSkeleton;
|
type Skeleton = CharacterSkeleton;
|
||||||
type Dependency = (Option<Tool>, f64);
|
type Dependency = (Option<Tool>, Vec3<f32>, Vec3<f32>, f64);
|
||||||
|
|
||||||
fn update_skeleton(
|
fn update_skeleton(
|
||||||
skeleton: &Self::Skeleton,
|
skeleton: &Self::Skeleton,
|
||||||
(_active_tool_kind, _global_time): Self::Dependency,
|
(_active_tool_kind, orientation, last_ori, _global_time): Self::Dependency,
|
||||||
anim_time: f64,
|
anim_time: f64,
|
||||||
_rate: &mut f32,
|
_rate: &mut f32,
|
||||||
skeleton_attr: &SkeletonAttr,
|
skeleton_attr: &SkeletonAttr,
|
||||||
@ -27,6 +27,20 @@ impl Animation for RollAnimation {
|
|||||||
let wave_slow = (anim_time as f32 * 2.8 + PI).sin();
|
let wave_slow = (anim_time as f32 * 2.8 + PI).sin();
|
||||||
let wave_dub = (anim_time as f32 * 5.5).sin();
|
let wave_dub = (anim_time as f32 * 5.5).sin();
|
||||||
|
|
||||||
|
let ori = Vec2::from(orientation);
|
||||||
|
let last_ori = Vec2::from(last_ori);
|
||||||
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
|
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
||||||
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
|
.reduce_and()
|
||||||
|
&& ori.angle_between(last_ori).is_finite()
|
||||||
|
{
|
||||||
|
ori.angle_between(last_ori).min(0.5)
|
||||||
|
* last_ori.determine_side(Vec2::zero(), ori).signum()
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
} * 1.3;
|
||||||
|
|
||||||
next.head.offset = Vec3::new(
|
next.head.offset = Vec3::new(
|
||||||
0.0 + skeleton_attr.neck_right,
|
0.0 + skeleton_attr.neck_right,
|
||||||
-2.0 + skeleton_attr.neck_forward,
|
-2.0 + skeleton_attr.neck_forward,
|
||||||
@ -102,7 +116,7 @@ impl Animation for RollAnimation {
|
|||||||
|
|
||||||
next.torso.offset =
|
next.torso.offset =
|
||||||
Vec3::new(0.0, 11.0, 0.1 + wave_dub * 16.0) / 11.0 * skeleton_attr.scaler;
|
Vec3::new(0.0, 11.0, 0.1 + wave_dub * 16.0) / 11.0 * skeleton_attr.scaler;
|
||||||
next.torso.ori = Quaternion::rotation_x(wave_slow * 6.5);
|
next.torso.ori = Quaternion::rotation_x(wave_slow * 6.5) * Quaternion::rotation_y(tilt);
|
||||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ impl Animation for RunAnimation {
|
|||||||
|
|
||||||
let ori = Vec2::from(orientation);
|
let ori = Vec2::from(orientation);
|
||||||
let last_ori = Vec2::from(last_ori);
|
let last_ori = Vec2::from(last_ori);
|
||||||
|
|
||||||
let tilt = if Vec2::new(ori, last_ori)
|
let tilt = if Vec2::new(ori, last_ori)
|
||||||
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
|
||||||
.map(|m| m > 0.001 && m.is_finite())
|
.map(|m| m > 0.001 && m.is_finite())
|
||||||
|
@ -280,7 +280,7 @@ impl FigureMgr {
|
|||||||
),
|
),
|
||||||
(_, Roll { .. }) => anim::character::RollAnimation::update_skeleton(
|
(_, Roll { .. }) => anim::character::RollAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
(active_tool_kind, time),
|
(active_tool_kind, ori.0, state.last_ori, time),
|
||||||
state.action_time,
|
state.action_time,
|
||||||
&mut action_animation_rate,
|
&mut action_animation_rate,
|
||||||
skeleton_attr,
|
skeleton_attr,
|
||||||
|
Loading…
Reference in New Issue
Block a user