- Home /
Help scoring Points In a Jousting game
So I'm having trouble getting point scoring working in my jousting game. I need it where when then lance hits the gridded gran guard that it will score you a point. Iv tried looking up previous answers and using it on this but with no success. I have a GUI Text layer so you can see the score. If anyone can be any help it would be much appreciated.
I know little of scripting and at the moment Im inbetween scripts. Been looking up what ppl have posted on similar things. I can tell you what I want the game to do tho, maybe that will help. The two players are co$$anonymous$$g at eachother on a set path. The player is holding the Lance and can move it with the mouse, I want when the lance makes contact with the Gridded gran guard on the other player when passing to score a point.
Doesn't really matter what kind of game it is anyone is making, be it about picking flowers and catching butterflies or about turning zombies into rotten hamburger with a chainsaw ; scoring points is scoring points.
You need a number, you need to increment it, and you need a condition that deter$$anonymous$$es when it gets incremented and by how much. (your condition here being the collision between the lance and the guard)
Collision, Score, Increment, Value, Points--> [SearchBar]
Answer by Woutervd · Apr 30, 2012 at 07:16 PM
This is quite similar to something I'm trying. It's not a complete solution but maybe it helps.
First place a script in your game to track the score, such as this (with filename PointSystem.js):
static var score = 0;
var scoreDisplay: GUIText;
function Update(){
scoreDisplay.text = "Score: "+score.ToString();
}
Then give the 'griddled gran gaurd' a script to actually change the score when the lance collides with it. For instance this:
function OnCollisionEnter(collision:Collision)
{ if( collision.gameObject.tag == "Lance" )
{
PointSystem.score = PointSystem.score+1;
}
}
That should work at least a bit. It might require some modification though.
I just did this and I have no errors but its not updating the score when my lance touches it, I have the Pointsystem script on the GUI Text layer and the 2nt on the gridded gran guard.
$$anonymous$$ake sure you have applied the tag 'Lance' to your lance. Or else exchange "Lance" in the bottom script for Player and on your lance apply the player tag from the presets in the dropdown list at the top of the inspector.
Have done both with same result of nothing, idk whats wrong >.>. does it matter what kind of collider is on the guard or lance? I have a box collider on the guard and have is trigger selected.
Turn off the trigger. OnCollision won't fire if it's a trigger collider.
Ugh, done that same result. I dont know what else to do to get it to work.
Your answer
Follow this Question
Related Questions
Collision and score 1 Answer
Is there another way of counting Scores (points) instead of Colliding (destroying) 1 Answer
How can I make my score counter increase incrementally and not jump from 0 to 100? 2 Answers
Scoring (i'm stuck) 3 Answers
Question about Point adding / Destroying after collision. 0 Answers