Billiard Template

Latest Version 1.0 - Released

Billiard Template
Links: [Asset Store] [Discord]

About:
Billiard Game Template for Unity is an event-based billiard physics engine in which differential equations of motion are solved exactly, thus creating a simulation that conforms to reality. This method is much faster than conventional solvers used in physics engines as it does not have an explicit simulation step but rather a search is performed for the next event(state change) when the differential equation to be solved is updated. Differential equations are solved analytically so precision only depends on the model!

Features:

  • Event-Based Physics Engine
  • Finite State Machine Gameplay
  • Fast And Stable Solvers
  • 6-DOF Ball Movement
  • Impulse-Based Collision Response With Friction
  • Double precision
  • Threaded solver using Jobs and Burst Compilation
  • 8Pool Example
  • And more!

Todo:

  • Network
  • VR Support
  • Android Support

Support:
Email: onedragutin@gmail.com
Website: https://nitugard.pages.dev/
Documentation: https://billiarddocs.pages.dev/
Asset: Billiard Template | Systems | Unity Asset Store

Initial version 1.0 is now available on the asset store!

If you have any questions I’ll be happy to answer :slight_smile:

The board returns to the starting state after the stroke,I don’t know where it was configured

Hello @povit ,

If the initial strike does not satisfy common eight pool ball rules, then the board is reset to previous(initial) state.
You can change this behavior in BilliardTemplate/Code/Billiard/EightPool/EightPoolBilliard.cs

I am working on making billiard template simpler to use and edit. Will post results soon.

For single player game, how does it handle computer ai ? is there a way to handle the actions on code? can you get the probabilities to know what would be the best action to take.

thanks in advance

Hello @LoveAndDreams ,

Here’s how the AI integration works:

1. Handling Computer AI:
The billiard simulation is designed to be event-driven, eliminating the need for simulating by incrementing delta time steps. This streamlined approach simplifies the AI integration process, enhances efficiency, and results in more intelligent AI behaviors. This represents a cutting-edge approach in game development.

2. Handling Actions in Code:
Yes, you can handle AI actions in code. You’ll need to define AI behavior, evaluate game states, and make decisions based on the current situation.

3. Probabilities for Best Action:
The billiard simulation is deterministic, so there are no inherent probabilities involved. However, you have the flexibility to introduce uncertainty if desired, making the AI choose suboptimal shots in some cases.

It’s worth noting that I’ve previously implemented AI using this template. The AI selected the best shot by simulating event-driven outcomes and considering the resulting table state. If you need assistance or have more questions, feel free to ask here or on our Discord for faster replies.

Thank you for the fast response. Your asset seems to be good at a good price. Does it include 2vs2?

No, it is just a core template with very realistic physics. You have the freedom to turn it into any kind of game you want.

Hi, Looks like a very nice billiard template.
One question I have though is if there is support for applying spin to the cue ball (Backspin, side spin, etc.)? I see that the physics simulation has 6DOF and support for sliding states etc. so it seems like the physics can handle that, but I cannot see any obvious way from the videos to input cue ball spin, and no reference in the documentation. Is that a supported feature and if not do you think it could be added in the future?
Also is the physics simulation deterministic? For example: if you take the same table state and inputs and simulate them on 2 different devices, will the outcome be identical?
Thanks in advance.

1 Like

Hello @scottyboy805

Certainly, the physics simulation in the billiard template accounts for various types of spins. I’m excited to share this Android game with you, which was created using my billiard template. As they say, a video is worth a thousand pictures, so I invite you to take a look:

Feel free to explore the immersive experience and witness the realistic spin mechanics in action. Let me know your thoughts!

2 Likes

Great work indeed! Well done. Now to convince the “better-half”…Her indoors!

1 Like

protected override void OnStableStateChange(bool isStable)
The parameters of this method represent whether the batting is completed, but it will be called multiple times in the Android environment. The iOS environment is normal. How can it be made normal in the Android environment?

Hello,

I’d be happy to assist you in resolving the issue you are experiencing. To better understand and address the problem, could you please provide more context or details about the issue you’re facing?

If you’d like, you can also contact me on Discord.

Regards.

Hi!
The game is not published yet, as far as I know.
Best Regards.

Do it handles every type of shoots? (Masse, Jump Break, Topspin and Backspin Screw…)

Hi @Magic73

The billiard template can of course simulate all these shots. It is the result of realistic billiard simulation.

are there some video about these shots, or a webgl/apk demo version where is it possibile to try?

Not for the time being, I’ve had a few requests for the demo in the past and I’m trying to find some free time to work on it.
So expect it in the future.

I am also online on discord most of the time, so you can dm me.

ok, but consider that your asset costs $300, not a small amount. It’s important to have at least a demo to actually check what physics can do and what it can’t.
Furthermore, an open source version of an event-driven 3D engine is already available (Pooltool just underwent a massive graphics overhaul – Evan Kiefl), and even if in Python, it is not a great job to port it to unity (I made one myself a few years ago).
The problem with this version (well done, and well documented and described by a blog) is that it does not manage the physics on the vertical plane (hence the jumps) and has a bug in the physics relating to the hit of the cue on the ball. I pointed this out, complete with demonstration and comparison videos between real and simulated, but then the discussion degenerated, and the author was not very inclined to accept observations of this type, so much so that he then even deleted the entire thread on github .

even if you don’t have time to make a demo, at least a video with the main shots that can be performed (jump, masses, english, forward, backward and so on)

like this: https://www.youtube.com/watch?v=-D_oSnAiFPA

(ShootersPool is the reference for billiard physics simulators, capable of reproducing 1 to 1 any type of shot that can be made in reality by performing exactly the same shot)