- Home /
Gap Between Two terrain ...
I am developing the racing game in which i have problem in connecting two terrain.
I have 3 terrain and all of them are repeating one after another when one reach the certain position , it will be placed at the after the last track. everything is going fine but problem is that it leaves gap between two terrain.
how to solve that? plz help me ...
here is my code
TrackA.cs
using UnityEngine; using System.Collections;
public class ATrack : MonoBehaviour {
public Transform ObjectA;
public GameObject TrackC;
void Start () {}
void FixedUpdate ()
{
if(Mathf.CeilToInt(ObjectA.transform.position.z) <= 0)
{
//gameObject.renderer.bounds
//Debug.Log(Vector3.up);
Vector3 temp = transform.position;
//temp.z = TrackC.transform.position.z + _TargetExtents.z/2;
temp.z = TrackC.transform.position.z + 200.0f;
temp.x = 10.0f;
temp.y = 0.0f;
transform.position = temp;
//Debug.Log(temp);
}
}
}
TrackB.cs
using UnityEngine; using System.Collections;
public class BTrack : MonoBehaviour {
public Transform ObjectB;
public GameObject TrackA;
void Start () { }
void FixedUpdate ()
{
if(Mathf.CeilToInt(ObjectB.transform.position.z) <= 0)
{
Vector3 temp = transform.position;
temp.z = TrackA.transform.position.z + 200.0f;
temp.x = 10.0f;
temp.y = 0.0f;
transform.position = temp;
}
}
}
TrackC.cs
using UnityEngine; using System.Collections;
public class CTrack : MonoBehaviour {
public Transform ObjectC;
public GameObject TrackB;
void Start ()
{
}
void FixedUpdate () {
if(Mathf.CeilToInt(ObjectC.transform.position.z) <= 0)
{
Vector3 temp = transform.position;
temp.z = TrackB.transform.position.z + 200.0f;
temp.x = 10.0f;
temp.y = 0.0f;
transform.position = temp;
}
}
}
Answer by Vipul-Dudharejiya · Jun 03, 2015 at 06:02 AM
Another Better Solution is moving car ahead instead of Terrain which will allow to place the terrain at the sane position where we want to put .
which will reduce the problem of floating point gap..
Answer by SkaredCreations · Dec 17, 2014 at 11:18 AM
It's probably a float number issue, may be the objects are not exactly 200f. What's the problem in reducing the 200f into lower number until you find it fits?
thnx for ur reply ... i have fixed it already... i have moved my track from 200 to 199 and its done ...