Casey has shown how to add a scrolling camera by setting the camera position to the player entity at the end of the simulation.
I wanted to try and add a slight delay to the camera movement to give a elastic movement so it's slightly slower than the player when following and then when the player stops the camera continues animating until the player is at the centre.
Also I wanted to be able to move the camera to show upcoming areas etc.
So I tried to attempt this but I am getting a bit confused when it comes to world positions and chunks and offsets...
So in theory I know how to animate a movement. I get the difference between the camera and player and normalise that to get a direction and then move by multiplying the direction and a speed constant along with the delta time of the frame. But when it comes to translating that into world space I have no idea.
I attempted something like:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17  |     if (entity->StorageIndex == worldMode->CameraFollowingEntityIndex)
    {
        Vector3 start = worldMode->CameraPosition.Offset;
        Vector3 end = storedEntity->Position.Offset;
        float speed = 10.0f;
            
        float distance = Length(end - start);
        Vector3 direction = Normalise(end - start);
        if(distance > 0)
        {
            worldMode->CameraPosition = MapIntoChunkSpace(
                worldMode->World,
                worldMode->CameraPosition,
                start + direction * speed * deltaTime);
        }
    }
 
 | 
 
But this just results in a bit of a mess. Can anyone explain how I can achieve this?
Am I going about this the right way?