How does this actually work to keep me in bounds when worldPos = worldPosLastFrame but worldPosLastFrame = worldPos? Isn’t this just assigning “worldPos” a value of itself?
this is how I understood it:
“worldPosLastFrame” is being stored from the last calculated frame before you would update your worldPos.
Then you can reset your new calculation of worldPos to worldPosLastFrame in case worldPos would otherwise be outside of the map borders.
Because the reset of worldPos happens before the map has been drawn, we don’t see the map moving at all.
or in other words:
“worldPos = worldPosLastFrame” is executed at a later time than “worldPosLastFrame = worldPos”. In between both assignments worldPos usually changes due to movement.
If the movement would make the character leave the map boundries, the movement gets undone by resetting worldPos back to the recently assinged worldPosLastFrame.
hope I could help!
That is 100% correct, bravo!
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.