Wilden Dawn

Interactive organism following

By Robin Dowling ยท 5 months ago

Watching thousands of organisms move across the simulation is interesting, but it can be hard to focus on any individual. I wanted a way for observers to follow specific organisms, tracking their movements and behaviors over time.

Following an organism changes how you experience the simulation. Instead of watching the ecosystem as a whole, you see the world from one organism's perspective. You watch it search for food, flee from threats, find mates, reproduce. You see its children born and follow them as they live their own lives. You witness the micro-decisions that create the macro patterns of evolution.

The solution was to make organisms clickable. Click on any organism and the camera follows it, keeping it centered in your viewport as it moves through the world. Click the background to stop following and return to manual control.

Implementing this required coordination between client and server. When clicking on an organism, the client sends a message to the server identifying which entity to follow. The server maintains a map of which session is following which entity and updates the session's position to match the entity's position before each state broadcast. The client receives state updates with the camera automatically centered on the followed organism.

When an organism dies, the follow automatically ends, controlled from backend. If a client disconnects, the server cleans up the follow mapping. The system handles these edge cases without requiring manual intervention.

The click-to-follow mechanism also laid groundwork for future features. The message protocol includes a control interaction type, currently unused, that could eventually enable direct organism control rather than just observation.