generated from Persson-dev/Godot-Xmake
fix position sync issues
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include <godot_cpp/variant/utility_functions.hpp>
|
||||
|
||||
static const float WalkSpeed = 2.0;
|
||||
static const float RunSpeed = 5.0;
|
||||
static const float RunSpeed = 7.0;
|
||||
static const float JumpStrength = 15.0;
|
||||
static const float Gravity = 50.0;
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace godot;
|
||||
|
||||
void Player::_bind_methods() {}
|
||||
|
||||
Player::Player() {}
|
||||
Player::Player() : m_PeerId(0) {}
|
||||
|
||||
Player::~Player() {}
|
||||
|
||||
@@ -31,7 +31,9 @@ void Player::_ready() {
|
||||
DEV_ASSERT(m_Mesh);
|
||||
DEV_ASSERT(m_AnimationTree);
|
||||
|
||||
apply_floor_snap();
|
||||
set_position({0, 0, 0});
|
||||
set_velocity({0, 0, 0});
|
||||
|
||||
animate(0);
|
||||
}
|
||||
|
||||
@@ -39,6 +41,7 @@ void Player::_physics_process(float delta) {
|
||||
if (godot::Engine::get_singleton()->is_editor_hint())
|
||||
return;
|
||||
|
||||
move_and_slide();
|
||||
animate(delta);
|
||||
}
|
||||
|
||||
@@ -46,8 +49,10 @@ void Player::animate(float delta) {
|
||||
if (is_on_floor()) {
|
||||
m_AnimationTree->set("parameters/ground_air_transition/transition_request", "grounded");
|
||||
|
||||
if (get_velocity().length() > 0) {
|
||||
if (m_Speed == RunSpeed) {
|
||||
float speed = get_velocity().length();
|
||||
|
||||
if (speed > 0.2f) {
|
||||
if (speed >= RunSpeed) {
|
||||
m_AnimationTree->set("parameters/iwr_blend/blend_amount",
|
||||
godot::UtilityFunctions::lerp(
|
||||
m_AnimationTree->get("parameters/iwr_blend/blend_amount"), 1.0, delta * AnimationBlend));
|
||||
|
||||
Reference in New Issue
Block a user