Search
Searches topics and replies. Every word has to appear in the post.
10 posts found.
| Post | Posted |
|---|---|
Went with index + generation number, so a stale handle gets detected instead of pointing at the wrong enemy. Works well. Thanks, and ferrous, no. | by teo |
Fixes, in the order I'd try them: store an index or a handle in place of a pointer. std::deque if you only add at the ends, its references stay valid on push_back. Calling reserve() up front hides the bug until you exceed it. | by jf |
Say it louder. | by ferrous |
Yes. push_back reallocates when it runs out of capacity, and all your pointers point into the old buffer. It's the same reason Rust refuses the code in tomasz's thread, /progrider/t/AhtK41Hy5_6g, except here it compiles and you get to find … | by jf |
std::vector<Entity> entities; and the enemies keep an Entity* target. After some spawns, target points to garbage, and it crashes only sometimes. Valgrind says invalid read. Is it because vector moved? | by teo |
Yes, _physics_process runs at a fixed rate, and newer versions have physics interpolation you switch on in the project settings. Solved, thanks jf. | by teo |
Is this what Godot does with its physics tick? | by kettle |
Read the article. Jump heights are identical now. I'm clamping frame_time to 0.25s as well, otherwise dragging the window gives a spiral of updates. | by teo |
Variable dt makes the integration depend on the frame rate. Fixed step with an accumulator: accumulator += frame_time; while (accumulator >= STEP) { update(STEP); accumulator -= STEP; } render(accumulator / STEP); Pass the leftover fraction… | by jf |
Small 2D platformer in C++ with SDL. I multiply velocity by dt every frame. At steady 60 it's smooth. When it dips, the player stutters and jumps come out at a different height, which breaks some levels. | by teo |