mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed running animation, changed movement physics
Former-commit-id: 1b4c1f63701668074874aa6efc65f883f29e2cc1
This commit is contained in:
parent
1e1b005cbb
commit
94fd0b1a22
@ -40,7 +40,7 @@ impl<'a> System<'a> for Sys {
|
||||
if on_ground {
|
||||
// TODO: Don't hard-code this
|
||||
// Apply physics to the player: acceleration and non-linear decceleration
|
||||
vel.0 += control.move_dir * 2.0 - vel.0.map(|e| e * e.abs() + e) * 0.03;
|
||||
vel.0 += control.move_dir * 4.0 - vel.0.map(|e| e * e.abs() + e) * 0.05;
|
||||
|
||||
if control.jumping {
|
||||
vel.0.z += 16.0;
|
||||
@ -48,7 +48,7 @@ impl<'a> System<'a> for Sys {
|
||||
} else {
|
||||
// TODO: Don't hard-code this
|
||||
// Apply physics to the player: acceleration and non-linear decceleration
|
||||
vel.0 += control.move_dir * 0.2;
|
||||
vel.0 += control.move_dir * 0.2 - vel.0.map(|e| e * e.abs() + e) * 0.002;
|
||||
}
|
||||
|
||||
let animation = if on_ground {
|
||||
|
@ -34,9 +34,9 @@ impl<'a> System<'a> for Sys {
|
||||
.get(pos.0.map(|e| e.floor() as i32))
|
||||
.map(|vox| !vox.is_empty())
|
||||
.unwrap_or(false)
|
||||
&& i < 80
|
||||
&& i < 100
|
||||
{
|
||||
pos.0.z += 0.005;
|
||||
pos.0.z += 0.0025;
|
||||
vel.0.z = 0.0;
|
||||
i += 1;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ impl Animation for IdleAnimation {
|
||||
next.weapon.ori = Quaternion::rotation_y(2.5);
|
||||
next.weapon.scale = Vec3::one();
|
||||
|
||||
next.torso.offset = Vec3::new(-0.5, 0.0, 0.1);
|
||||
next.torso.offset = Vec3::new(-0.5, -0.2, 0.1);
|
||||
next.torso.ori = Quaternion::rotation_x(0.0);
|
||||
next.torso.scale = Vec3::one() / 11.0;
|
||||
|
||||
|
@ -21,7 +21,7 @@ impl Animation for JumpAnimation {
|
||||
let wavetest = (wave.cbrt());
|
||||
let fuzzwave = (anim_time as f32 * 12.0).sin();
|
||||
let wavecos = (anim_time as f32 * 14.0).cos();
|
||||
let wave_slow = (anim_time as f32 * 5.0 + PI).sin();
|
||||
let wave_slow = (anim_time as f32 * 5.0 + PI).min(PI / 2.0).sin();
|
||||
let wave_slowtest = (anim_time as f32).min(PI/2.0).sin();
|
||||
let wavecos_slow = (anim_time as f32 * 8.0 + PI).cos();
|
||||
let wave_dip = (wave_slow.abs() - 0.5).abs();
|
||||
|
@ -11,9 +11,9 @@ pub struct RunAnimation;
|
||||
|
||||
impl Animation for RunAnimation {
|
||||
type Skeleton = CharacterSkeleton;
|
||||
type Dependency = f64;
|
||||
type Dependency = (f32, f64);
|
||||
|
||||
fn update_skeleton(skeleton: &Self::Skeleton, global_time: f64, anim_time: f64) -> Self::Skeleton {
|
||||
fn update_skeleton(skeleton: &Self::Skeleton, (velocity, global_time): Self::Dependency, anim_time: f64) -> Self::Skeleton {
|
||||
let mut next = (*skeleton).clone();
|
||||
|
||||
let wave = (anim_time as f32 * 14.0).sin();
|
||||
@ -60,8 +60,8 @@ impl Animation for RunAnimation {
|
||||
next.weapon.ori = Quaternion::rotation_y(2.5);
|
||||
next.weapon.scale = Vec3::one();
|
||||
|
||||
next.torso.offset = Vec3::new(-0.5, 0.0, 0.2);
|
||||
next.torso.ori = Quaternion::rotation_x(-0.25 - wavecos * 0.1);
|
||||
next.torso.offset = Vec3::new(-0.5, -0.2, 0.2);
|
||||
next.torso.ori = Quaternion::rotation_x( - velocity * 0.05 - wavecos * 0.1);
|
||||
next.torso.scale = Vec3::one() / 11.0;
|
||||
|
||||
next.l_shoulder.offset = Vec3::new(3.0, 6.0, 18.0);
|
||||
|
@ -191,9 +191,10 @@ impl FigureCache {
|
||||
pub fn maintain(&mut self, renderer: &mut Renderer, client: &mut Client) {
|
||||
let time = client.state().get_time();
|
||||
let ecs = client.state_mut().ecs_mut();
|
||||
for (entity, pos, dir, character, animation_history) in (
|
||||
for (entity, pos, vel, dir, character, animation_history) in (
|
||||
&ecs.entities(),
|
||||
&ecs.read_storage::<comp::phys::Pos>(),
|
||||
&ecs.read_storage::<comp::phys::Vel>(),
|
||||
&ecs.read_storage::<comp::phys::Dir>(),
|
||||
&ecs.read_storage::<comp::Character>(),
|
||||
&ecs.read_storage::<comp::AnimationHistory>(),
|
||||
@ -210,13 +211,11 @@ impl FigureCache {
|
||||
IdleAnimation::update_skeleton(&mut state.skeleton, time, animation_history.time)
|
||||
},
|
||||
comp::character::Animation::Run => {
|
||||
RunAnimation::update_skeleton(&mut state.skeleton, time, animation_history.time)
|
||||
RunAnimation::update_skeleton(&mut state.skeleton, (vel.0.magnitude(), time), animation_history.time)
|
||||
},
|
||||
comp::character::Animation::Jump => {
|
||||
JumpAnimation::update_skeleton(&mut state.skeleton, time, animation_history.time)
|
||||
},
|
||||
// TODO
|
||||
// JumpAnimation::update_skeleton(&mut state.skeleton, time)
|
||||
};
|
||||
|
||||
state.skeleton.interpolate(&target_skeleton);
|
||||
|
@ -53,7 +53,7 @@ impl World {
|
||||
let chaos = chaos_nz.get(Vec2::from(wposf * chaos_freq).into_array()).max(0.0) + 0.5;
|
||||
|
||||
let height = perlin_nz.get(Vec2::from(wposf * freq).into_array()) * ampl * chaos
|
||||
+ perlin_nz.get(Vec2::from(wposf * small_freq).into_array()) * small_ampl * chaos
|
||||
+ perlin_nz.get((wposf * small_freq).into_array()) * small_ampl * chaos
|
||||
+ offs;
|
||||
let temp = (temp_nz.get(Vec2::from(wposf * (1.0 / 64.0)).into_array()) + 1.0) * 0.5;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user