Unity Learn home
1
0
Stonesthrow v0.1
33 views
Play on Unity Play

A curling-inspired game complete with sweeping mechanics and curved trajectories based on stone rotation.

Points are scored based on each stone's distance to the target after the round ends. Sweeping in front of a stone will decrease drag, sending the stone further and reducing the effect of spin while traveling across a swept surface.

Design Document

Commentary

I spent way too much time on this prototype - but I wanted to see what I was capable of at this early juncture. I'm happy with how it's turned out, and the scale of the project was just right - not so small or simple that it wasn't challenging or didn't force me to go out and learn more, and not so large and complex that I felt completely overwhelmed.

Simulating the stone's trajectory and setting up box colliders for sweep lines were admittedly both overly-ambitious and somewhat mindbending, but I'm happy I followed through and managed to tackle them.

While it doesn't embody much of a game in it's current state, I think this prototype could be relatively easily expanded upon with local turn-based multiplayer, a simple AI opponent, or even "levels" of a sort involving opponent's stones or other obstacles pre-positioned or fired per-turn into challenging arrangements with a score threshold to complete the level.

Implementation Notes

The game-state management was inspired by Tarodev

The trajectory simulation was also inspired by Tarodev. A sub-scene is spawned along with a clone of the gameplay plane and a stone, then the subscene's physics are manually stepped, and the cloned stone's position at each step added to a LineRenderer.

Game state changes are propagated to other managers via Actions allowing things like camera movement, input map switching, and state-transition sound effects to be easily orchestrated.

The sweep effects are managed by a "Sweep Line Manager" which uses a circular array to keep track of a fixed number of objects with LineRenderer components. The manager creates a new line when the left mouse button is first depressed, then creates a new point each time the distance to the last point exceeds a certain threshold.

A fixed number of "sweep colliders" to reduce stone drag are pooled and placed in between the most recently placed points on the active sweep line, scaled on the Z axis to match the distance between points, and rotated to face the next point.

ChatGPT assisted in the implementation of a mechanism to "curl" a stone's trajectory. This works by adding a force determined by the RB's angular velocity and radius perpendicular to (and scaled down by) it's translational velocity each FixedUpdate().

Stone objects are pooled and reused between games/rounds. If the player increases the number of stones per round on the menu, additional stones are instantiated into the pool at the start of the next game.

A "Stone Manager" handles spawning, activating, deactivating, applying initial forces to, and scoring all of the stones. The "Stone Controller" on each stone only handles the "curling" physics force, changes to the RB's drag, and passing collision events up to the Stone Manager so the Sound Manager can react.

Input is handled with the newer Unity Input System, with a dedicated "Input Manager" object containing the sole PlayerInput component. The manager subscribes to game state updates, and switches between "Delivery" (shooting) and "Sweeping" action maps - or disabling input entirely - depending on the current game state.

The stone and broom meshes were created using ProBuilder.

Third-Party Assets

  • Sound effects
  • Sonniss GDC collection
  • Universal Sound FX (via a Humble Bundle)
  • Music
  • Big Casual & Arcade Game Music Bundle (via Humble Bundle)
  • Models
  • Arrow meshes from Synty Prototype Pack (via Humble Bundle)
  • Skybox
  • Starfield Skybox
Media
1
6