- Home /
creating race game
hi,
im new in using unity so i dunno how to make a racing game ... so my question is how can i create starting point in my terrain?
Don't ask broad questions here. Ask specific ones ins$$anonymous$$d, like "How do I create terrain?" or "How do I create a spawnpoint?".
His question does seem to be "How do I create a spawnpoint"?
Answer by sovalopivia · Jul 27, 2010 at 10:32 AM
If you're new then looking through fully fledged tutorials might be more useful to you. http://unity3d.com/support/resources/tutorials/car-tutorial Is specifically about how to set up a controllable car, how handy! and there are other tutorials there as well for other basic concepts.
But to answer your question; when you add a GameObject in Unity you can set its transform position in the inspector window, This is its position.
Or you could drag it around in the scene view.
If you just leave it like this it will start at the position you leave it in the scene view, but you can also set the car's position using scripting. In a script attached to the car you can use the Start()
or Awake()
function, which are only called once each, to set a starting position, like this.
void Start()
{
transform.position.x = 5.0f;
transform.position.y = 10.0f;
transform.position.z = 30.6f;
}
or this
void Start()
{
transform.position = new Vector3(5.0f, 10.0f, 30.6f)
}
Answer by karthik · Jul 27, 2010 at 10:56 AM
Just go through this link you will easily understand the mechanism for developing Car Race.
Answer by spinaljack · Jul 27, 2010 at 09:49 AM
Use a box collider set to trigger so that when cars pass through it you know they've reached that check point.
e.g.
function OnTriggerEnter(other : Collider){
if(other.CompareTag("Car")){
other.gameObject.SendMessage("CheckPoint",1);
}
}
On the car:
function CheckPoint(number : int){
currentCheckPoint = number;
}
Then it's a simple case of making a string of check points from start to finish and checking that every car has passed through them all.
If you wanted to instantiate a set of cars at the start can just create an array of start points on the starting grid.
Can you tell me where to add these two scripts to the Unity Car Tutorial please ,I added them but nothing seems to happen :(
Your answer
Follow this Question
Related Questions
Diamond Square Algorithm 2 Answers
Make a simple tree 1 Answer
How would I flip or mirror Terrain data during runtime? 1 Answer
Making changes to a terrian in game 1 Answer
Tracking information across terrain 1 Answer