Hi , all , i’m working on a bowling mini game project and so far i’ve done a pretty good job , however i’m now stuck with the score count of a bowling game wich appears very hard to implement from the researches i’ve done on the internet ,and i dont know if this problem have been resolved previously , so can somebody please help me to find the solution , thnx.
You could use OnCollisionEnter to increment the score by however many you want when the bowling ball and pin collide Unity - Scripting API: Collider.OnCollisionEnter(Collision)
There is a sample Unity bowling project for sale that may help:
which also refers to this:
http://www.whereisdeniss.com/applications/bowling-score-keeper-c-mono-project-java-eclipse
Are you having trouble determining if the pin has fallen or how to calculate the actual score? Put two colliders on a pin, one that it stands on (very short at bottom) and one for the rest of the pin. If the one on the upper part of the pin touches the alley, then it’s down. The score itself is pretty easy, so I’m assuming you didn’t mean that
Adding the score is a little tricky. I created a bowling game not long ago. and had to google the rules of the game cause i was confused how bonus points are added up.
My Version
Before i get into that though i would like to share the method i used for the pins. I used a trigger/box over the whole rack two thirds the way up the pin. This way if any pins fell over they would return value OnTriggerExit. each pin had a tag name so that i could tell what pins fell over. This way i could load the second shot of the spare with the exact pin configuration of the standing pins. Worked like a charm.
The strikes are easy to add up and move on to the next frame. The bonus points overlap each other though if you pickup the spare and then get a strike. somehow you receive points for the next two shots. I’m so armature at bowling that it totally confused me. So i went with just adding up the pins wit no bonus points for now. lol
Here is the info straight off google below.
Rules of playA game of bowling consists of ten frames. In each frame, the bowler will have two chances to knock down as many pins as possible with his bowling ball. In games with more than one bowler, as is common, every bowler will take his frame in a predetermined order before the next frame begins. If a bowler is able to knock down all ten pins with the first ball, he is awarded a strike. If the bowler is able to knock down all 10 pins with the two balls of a frame, it is known as a spare. Bonus points are awarded for both of these, depending on what is scored in the next 2 balls (for a strike) or 1 ball (for a spare). If the bowler knocks down all 10 pins in the tenth frame, the bowler is allowed to throw 3 balls for that frame. This allows for a potential of 12 strikes in a single game, and a maximum score of 300 points, a perfect game.
ScoringIn general, one point is scored for each pin that is knocked over. So if a player bowls over three pins with the first shot, then six with the second, the player would receive a total of nine points for that frame. If a player knocks down 9 pins with the first shot, but misses with the second, the player would also score nine. When a player fails to knock down all ten pins after their second ball it is known as an open frame.
In the event that all ten pins are knocked over by a player in a single frame, bonuses are awarded.
A ten-pin bowling scoresheet showing how a strike is scoredstrike: When all ten pins are knocked down with the first ball (called a strike and typically rendered as an “X” on a scoresheet), a player is awarded ten points, plus a bonus of whatever is scored with the next two balls. In this way, the points scored for the two balls after the strike are counted twice.
Frame 1, ball 1: 10 pins (strike)
Frame 2, ball 1: 3 pins
Frame 2, ball 2: 6 pins
The total score from these throws is:
Frame one: 10 + (3 + 6) = 19
Frame two: 3 + 6 = 9
TOTAL = 28
Two consecutive strikes are referred to as a “double”.
A double’s pinfall is:
Frame 1, ball 1: 10 pins (Strike)
Frame 2, ball 1: 10 pins (Strike)
Frame 3, ball 1: 9 pins
Frame 3, ball 2: 0 pins (recorded as a dash ‘-’ on the scoresheet)
The total score from these throws is:
Frame one: 10 + (10 + 9) = 29
Frame two: 10 + (9 + 0) = 19
Frame three: 9 + 0 = 9
TOTAL = 57
Three strikes bowled consecutively are known as a “turkey” or “triple”.
A triple’s pinfall is:
Frame 1, ball 1: 10 pins (Strike)
Frame 2, ball 1: 10 pins (Strike)
Frame 3, ball 1: 10 pins (Strike)
Frame 4, ball 1: 0 pins (Gutterball)
Frame 4, ball 2: 9 pins
The total score from these throws is:
Frame one: 10 + (10 + 10) = 30
Frame two: 10 + (10 + 0) = 20
Frame three: 10 + (0 + 9) = 19
Frame four: 0 + 9 = 9
TOTAL = 78
Any longer string of strikes is referred to by a number attached to the word “bagger”, as in “five-bagger” for five consecutive strikes. Recently, the event of bowling four consecutive strikes has also been called a “hambone”. [24] This terminology is used most often when a bowler is “off the strikes”. (i.e. has previously bowled a string of several strikes but failed to strike on his most recent ball.) When a player is “on the strikes”, a string is often referenced by affixing “in a row” to the number of strikes bowled consecutively. Six strikes in a row are sometimes referred to as a “six pack”.[25][26] Six strikes and nine strikes in a row can also be referred to “Wild Turkeys” and “Golden Turkeys” respectively. Any string of strikes starting in the first frame or ending “off the sheet” (where all of a bowler’s shots from a certain frame to the end of the game strike) are often referred to as the “front” or “back” strikes, respectively (e.g. the “front nine” for strikes in frames 1–9, or the “back six” for strikes in frames 7, 8, and 9 with a turkey in the tenth). A “perfect game” or 12 strikes in a row is also colloquially referred to as the “Thanksgiving Turkey”. Remember that will be No Pass Pins, No Spares during our last 10th C Frame.
A player who scores multiple strikes in succession would score like so:
Frame 1, ball 1: 10 pins (strike)
Frame 2, ball 1: 10 pins (strike)
Frame 3, ball 1: 4 pins
Frame 3, ball 2: 2 pins
The score from these throws are:
Frame one: 10 + (10 + 4) = 24
Frame two: 10 + (4 + 2) = 16
Frame three: 4 + 2 = 6
TOTAL = 46
The most points that can be scored in a single frame is 30 points (10 for the original strike, plus strikes in the two subsequent frames).
A player who bowls a strike in the tenth (final) frame is awarded two extra balls so as to allow the awarding of bonus points. If both these balls also result in strikes, a total of 30 points (10 + 10 + 10) is awarded for the frame. Some people call it “striking out”, since three strikes in baseball equals an out. These bonus points do not count on their own, however. They only count as the bonus for the strike.
A ten-pin bowling scoresheet showing how a spare is scoredspare: A “spare” is awarded when no pins are left standing after the second ball of a frame; i.e., a player uses both balls of a frame to clear all ten pins. A player achieving a spare is awarded ten points, plus a bonus of whatever is scored with the next ball (only the first ball is counted). It is typically rendered as a slash on scoresheets in place of the second pin count for a frame.
Example:
Frame 1, ball 1: 7 pins
Frame 1, ball 2: 3 pins (spare)
Frame 2, ball 1: 4 pins
Frame 2, ball 2: 2 pins
The total score from these throws is:
Frame one: 7 + 3 + 4 (bonus) = 14
Frame two: 4 + 2 = 6
TOTAL = 20
A player who bowls a spare in the tenth (final) frame is awarded one extra ball to allow for the bonus points.
Correctly calculating bonus points can be difficult, especially when combinations of strikes and spares come in successive frames. In modern times, however, this has been overcome with automated scoring systems, linked to the machines that set and clear the pins between frames. A computer automatically counts pins that remain standing, and fills in a virtual score sheet (usually displayed on monitors above each lane). However, even the automated system is not fool-proof, as the computer can miscount the number of pins that remain standing.
A pin’s local x and z will be at or near zero if the pin is still standing.
thnx a lot guys , i was just so confused about what i found on internet concerning score calculation , yet i still have algorithmic problems about how to make a condition that will succeed an another , for example how can i make score in frame one wait until frame 2 is played then calculate the score of frame 1 ??
Arrays
If(score[0] != null) print frame 1
if(score[1] != null) print frame 2
…
The same can be done when calculating scores
yes ,thank you BigMisterB , arrays are a part of the solution ,to display the result of the score in a bulletin board I used GUIText I assigned to a table of GUIText takes successive values of each frame .
Hello,
This might help you understand the algorithm better: Uncle Bob’s Bowling Game Kata | Programming Praxis
Scroll down a bit and see the 3rd or 4th comment. This is what you need. Its written in Java, but i don’t think you will have any problems.
Hello!
I did something like this but a little different.
instead of full length u used triggers from top to the middle of the pins and instead if OnTriggerExit() i used OnTriggerEnter() to detect collision with the floor.
worked reallty good but some how i could implement the scoring correctly…
Can you share your scoring script with me?
or give me directions?
i destroy the pins which fells down to the floor,
the fallen pins sends message to a a script which ads one to fallen pins.
this way i can easy detect which pins are down, the i destroy the down pins after 2 seconds and next frame starts.
There is a sample bowling game on github
part of my Apress book Learn Unity 4 for iOS Game Development (there is now an update: Lean Unity 2017 for iOS Game Development)
It’s a simplified version of the code in my HyperBowl bowling game. If I remember correctly, there’s a script on each pin that checks the y position to see if it’s knocked over. Although it can miss the case where the pin wobbles for a long time before falling over.
Thanks for your replay, i really appreciate the help, i will see the code if i can find the logic to keep the score,
every thing is working fine with me but i can’t apply the rules for scoring , like strikes and spears.
Thank you very much.