Flying PE_LIVING entity

Hello. I have some problems with setting up flying character.
What I do.
- in update event (ENTITY_EVENT_UPDATE) every frame I set entities gravity to zero

Code: Select all

pe_player_dynamics dynamics;
dynamics.gravity = Vec3(0.f, 0.f, 0.f);

- move entity by changing its velocity

Code: Select all

Vec3 moveDirection = ZERO;

pe_action_set_velocity vel;

if (IsMoving()) {
moveDirection.x = m_sProperties.m_fSpeedX;
moveDirection.y = m_sProperties.m_fSpeedY;
moveDirection.z = m_sProperties.m_fSpeedZ;


vel.v = GetEntity()->GetWorldRotation() * moveDirection / 30.f;

All works quite well, but, sometimes, entity starts to falling down for 1-2 frames, like gravity was affecting it and then it floats in air again normally. It happens every 3-4 seconds.

Am I missing something or my approach for flying character is completely wrong?

Who is online

Users browsing this forum: No registered users and 1 guest