4

Somehow in my engine when I do :

camPos.y += camUp.y * speed * deltaTime;

It goes faster than Trump seeing an underage girl,
and when I add up everything :
camPos.x += camUp.x * speed * deltaTime;
camPos.y += camUp.y * speed * deltaTime;
camPos.z += camUp.z * speed * deltaTime;

It goes as slow as my gf seeing me.
(jk arch users dont have gfs)

Also what keys could I map to go up and down ? WASD/ZQSD usually for right left back...
Space/ctrl?

Comments
  • 6
    > Space/ctrl?

    Yes.

    For your speed problem, no idea, but why don’t you use operator overloading and SIMD? It was invented for that exact use case.
  • 4
    Shift/CTRL and q/e are also common.
  • 2
    @Lensflare I would say llvm will take care auto vectorizing that but it's actually pretty bad when it comes to 3 dimensional vectors. The more you know!
  • 6
    There’s nothing wrong with your movement code besides the fact that you can reasonably expect it to be 3x as slow. Either there’s more to the story, or every time that code runs, a high energy charged particle from space strikes your PC’s RAM and causes a bit flip, somehow ruining performance.
  • 3
    @AlgoRythm LMAO god likes my code
  • 1
    @AlgoRythm Of course it needs to be slower !
  • 2
    @3dgoosee check your deltaTime calculation
  • 1
    @BordedDev lool it sucks like the rest of my code
  • 2
    @BordedDev float deltaTime = 0.0f;

    uint32_t lastFrame = 0;

    void updateDeltaTime(void) {

    uint32_t frame = SDL_GetTicks(); // current frame

    deltaTime = (frame - lastFrame) / 1000.0f; // seconds

    lastFrame = frame;

    }

    i dont see any probs
  • 1
    @3dgoosee Same to me, but check the actual value, floats can be funky, especially if you're running very quickly. That and check if it's not maybe called multiple times
  • 1
    @BordedDev i found out, my playerSpeed was just very slow!
  • 1
    @3dgoosee Nice, glad it's fixed
  • 1
    @BordedDev glew* its fixed
  • 1
Add Comment