mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
combine character.action movement blocks
This commit is contained in:
parent
9a832dd56b
commit
b81cd6a8f9
@ -83,14 +83,7 @@ impl<'a> System<'a> for Sys {
|
||||
.unwrap_or(Vec2::from(vel.0).try_normalized().unwrap_or_default())
|
||||
* ROLL_SPEED
|
||||
}
|
||||
if character.action.is_block() {
|
||||
vel.0 += Vec2::broadcast(dt.0)
|
||||
* controller.move_dir
|
||||
* match (physics.on_ground) {
|
||||
(true) if vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL,
|
||||
_ => 0.0,
|
||||
}
|
||||
} else if character.action.is_attack() {
|
||||
if character.action.is_block() || character.action.is_attack() {
|
||||
vel.0 += Vec2::broadcast(dt.0)
|
||||
* controller.move_dir
|
||||
* match (physics.on_ground) {
|
||||
|
@ -10,11 +10,11 @@ pub struct RunAnimation;
|
||||
|
||||
impl Animation for RunAnimation {
|
||||
type Skeleton = CharacterSkeleton;
|
||||
type Dependency = (f32, f64);
|
||||
type Dependency = (f32, f32, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
(velocity, global_time): Self::Dependency,
|
||||
(velocity, orientation, global_time): Self::Dependency,
|
||||
anim_time: f64,
|
||||
skeleton_attr: &SkeletonAttr,
|
||||
) -> Self::Skeleton {
|
||||
@ -38,6 +38,20 @@ impl Animation for RunAnimation {
|
||||
.sin()
|
||||
* 0.1,
|
||||
);
|
||||
|
||||
let vel = Vec2::from(velocity);
|
||||
let ori = (Vec2::from(orientation)).normalized();
|
||||
|
||||
let _tilt = if Vec2::new(ori, vel)
|
||||
.map(|v| Vec2::<f32>::from(v).magnitude_squared())
|
||||
.reduce_partial_min()
|
||||
> 0.001
|
||||
{
|
||||
vel.normalized().dot(ori.normalized()).min(1.0).acos()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-1.0 + skeleton_attr.neck_forward,
|
||||
@ -106,7 +120,8 @@ impl Animation for RunAnimation {
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, -0.2 + wave * -0.08, 0.4) * skeleton_attr.scaler;
|
||||
next.torso.ori =
|
||||
Quaternion::rotation_x(wave_stop * velocity * -0.06 + wave_diff * velocity * -0.005);
|
||||
Quaternion::rotation_x(wave_stop * velocity * -0.06 + wave_diff * velocity * -0.005)
|
||||
* Quaternion::rotation_y(0.0);
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
|
||||
next
|
||||
|
@ -711,7 +711,7 @@ impl FigureMgr {
|
||||
),
|
||||
Run => anim::character::RunAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(),
|
||||
(vel.0.magnitude(), time),
|
||||
(vel.0.magnitude(), ori.0.magnitude(), time),
|
||||
time_since_movement_change,
|
||||
skeleton_attr,
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user