|
Hi! I want to make a point system for my car game. Here is the code for jumping tricks (pretty simple) using System.Collections; public class Jumping : MonoBehaviour { public GameObject nissan350z; } } So I wondering if it's possible to make a system that each time I push 1,2,3,4 or 5, and land properly, I should get a certain amount of points. Thanks, any help will appreciated. PS: I am new in coding/scripting.
(comments are locked)
|
This code will add 5,10,15,20,25 relative to the number keys pressed (1,2,3,4,5) to a tmpScore variable. Now what you need is a way to determine if the car has landed properly... This could be done with colliders/triggers under the car or through a more complicated script. Once the car has landed properly you will need to add the tmpScore to the current score of your player. I will need more information about the game (Probably need to see a live demo) in order to figure out which solution would be best for checking if the car lands properly. Thank you veyr much for your reply! I have 4 wheelcolliders, so I was thinking, if a player lands properly with atleast 1 wheel on the terrain, he gets points for that. And the points should be counted in the small gui box. I hope you will be able to help me with that. Thanks in advance!
Apr 20 '12 at 08:59 PM
Kandak
You can try something like this. function OnCollisionEnter(collision : Collision) { if(collision.gameObject.name == "terrain"){ //Add score to player. } } Here's more help on OnCollisionEnter: http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html Here's some info about the Collision: http://unity3d.com/support/documentation/ScriptReference/Collision.html As for displaying the score on screen simply use: function OnGUI(){ GUI.Label(Rect(10, 10, 100, 25), "Score: "+Score); }
Apr 20 '12 at 11:37 PM
Flash
(comments are locked)
|
