Devlog #2 – Building Better Levels – Smart World Object Placement


Squirrel Launcher currently has a system where objects are placed alongside chunks. This works mostly fine, but it has a major issue: Obstacles can appear in ways that make it impossible to dodge. I could simply reduce the spawn rate of objects, but then there would be areas of the level with no obstacles instead of areas with too many obstacles. The best solution is to make a smarter object placement system. Instead of spawning objects alongside each chunk, objects would be spawned ahead of the squirrel’s movement.

 

This new system has more flexibility

When an object is placed out of the chunk system, it can look at various parameters and adjust its strategy accordingly:

  1. Player speed
  2. Fuel remaining
  3. HP remaining
  4. Level completion
  5. Player world position
  6. Player world altitude

These parameters (called influences) can affect the spawn rate of objects. For example, when you first start the game, no obstacles will be loaded, but after a you upgrade the squirrel a few times, obstacles will start appearing. This will also align gameplay to progressively introduce new obstacles and challenges.

In order for a level to spawn in objects using the new system. A scriptable object called a Smart Placement Node is created.

Technical – Smart Placement Nodes

Each node has an interval. The interval may be either a distance traveled by the player or an elapsed time. The interval is continuously modified based on influences such as the current altitude or remaining HP. Each influence is calculated from a function that takes in its statistic and outputs a value. The value of each influence is then multiplied to the base interval to get the actual interval.

Once an interval is met, the node picks a random object off of its object list. Then, it spawns the object ahead of the player’s trajectory with a slight amount of randomness. Finally, it starts the process over again and waits for its interval to be met again.

-----

Of course, most of the objects in the level will still use the old system. It works best with decorative objects as it will always be consistent.

I am currently working on refining the ocean level’s features, so expect a video on that in the future.

That’s all.

Thanks for reading.

                                                                                             

Get Squirrel Launcher

Leave a comment

Log in with itch.io to leave a comment.