Hello im not 100% sure if its a bug but it feels like it. I try to change the position for my player. But however he gets teleported back to the old position. I use a slight modifyed version of the FPS Controls.
How to reproduce:
Change the update function with the following code and press enter, wich sets the player to 0,0,0 and press any movement key after the position change.
void FirstPersonControls::Update()
{
Vec3 movement;
float jump = 0;
bool crouch = false;
auto entity = GetEntity();
auto window = ActiveWindow();
if (window)
{
if (!freelookstarted)
{
freelookstarted = true;
freelookrotation = entity->GetRotation(true);
freelookmousepos = window->GetMouseAxis();
}
auto newmousepos = window->GetMouseAxis();
lookchange.x = lookchange.x * mousesmoothing + (newmousepos.y - freelookmousepos.y) * 100.0f * mouselookspeed * (1.0f - mousesmoothing);
lookchange.y = lookchange.y * mousesmoothing + (newmousepos.x - freelookmousepos.x) * 100.0f * mouselookspeed * (1.0f - mousesmoothing);
if (Abs(lookchange.x) < 0.001f) lookchange.x = 0.0f;
if (Abs(lookchange.y) < 0.001f) lookchange.y = 0.0f;
if (lookchange.x != 0.0f or lookchange.y != 0.0f)
{
freelookrotation.x += lookchange.x;
freelookrotation.y += lookchange.y;
camera->SetRotation(freelookrotation, true);
}
freelookmousepos = newmousepos;
float speed = movespeed;// / 60.0f;
bool jumpkey = window->KeyHit(KEY_SPACE);
if (entity->GetAirborne())
{
speed *= 0.25f;
}
else
{
if (window->KeyDown(KEY_SHIFT))
{
speed *= 2.0f;
}
else if (window->KeyDown(KEY_CONTROL))
{
speed *= 0.5f;
}
if (jumpkey)
{
jump = jumpforce;
}
}
if (window->KeyDown(KEY_D)) movement.x += speed;
if (window->KeyDown(KEY_A)) movement.x -= speed;
if (window->KeyDown(KEY_W)) movement.z += speed;
if (window->KeyDown(KEY_S)) movement.z -= speed;
if (movement.x != 0.0f and movement.z != 0.0f) movement *= 0.707f;
if (jump != 0.0f)
{
movement.x *= jumplunge;
if (movement.z > 0.0f) movement.z *= jumplunge;
}
crouch = window->KeyDown(KEY_CONTROL);
if (window->KeyDown(KEY_ENTER)) {
this->GetEntity()->SetPosition(0, 0, 0);
this->currentcameraposition = this->GetEntity()->position;
}
}
entity->SetInput(camera->rotation.y, movement.z, movement.x, jump, crouch);
float eye = eyeheight;
float y = TransformPoint(currentcameraposition, nullptr, entity).y;
float h = eye;
if (y < eye) h = Mix(y, eye, 0.5f);
currentcameraposition = TransformPoint(0, h, 0, entity, nullptr);
camera->SetPosition(currentcameraposition, true);
}