void Awake() { int currentPoint = 0; List <Vector3> roadVertices = new List <Vector3> { new Vector3(-5f, 0f, -1f), new Vector3(5f, 0f, -10f), new Vector3(13f, 0f, 3f), new Vector3(8f, 0f, 0f), new Vector3(3f, 0f, -2f), }; GameObject spherePoint1 = Instantiate(spherePrefab); spherePoint1.transform.position = roadVertices[currentPoint]; _sphere1 = spherePoint1.GetComponent <SphereMovement>(); _sphere1.PositionChanged += OnSpherePositionChanged; _sphere1.GetComponent <MeshRenderer>().material = materialSphere1; GameObject spherePoint2 = Instantiate(spherePrefab); spherePoint2.transform.position = roadVertices[++currentPoint]; _sphere2 = spherePoint2.GetComponent <SphereMovement>(); _sphere2.PositionChanged += OnSpherePositionChanged; GameObject spherePoint3 = Instantiate(spherePrefab); spherePoint3.transform.position = roadVertices[++currentPoint]; _sphere3 = spherePoint3.GetComponent <SphereMovement>(); _sphere3.PositionChanged += OnSpherePositionChanged; GameObject spherePoint4 = Instantiate(spherePrefab); spherePoint4.transform.position = roadVertices[++currentPoint]; _sphere4 = spherePoint4.GetComponent <SphereMovement>(); _sphere4.PositionChanged += OnSpherePositionChanged; GameObject spherePoint5 = Instantiate(spherePrefab); spherePoint5.transform.position = roadVertices[++currentPoint]; _sphere5 = spherePoint5.GetComponent <SphereMovement>(); _sphere5.PositionChanged += OnSpherePositionChanged; _sphere5.GetComponent <MeshRenderer>().material = materialSphere2; // mesh GameObject road = new GameObject("MyRoad"); roadMeshFilter = road.AddComponent <MeshFilter>(); mesh = RoadMeshGenerator2.GenerateRoadMesh(roadVertices, roadWidth, radius); //RoadMeshGenerator2 roadGenerator = new RoadMeshGenerator2(); //mesh = roadGenerator.GenerateRoadMesh(roadVertices, roadWidth, radius); roadMeshFilter.sharedMesh = mesh; var meshRenderer = road.AddComponent <MeshRenderer>(); meshRenderer.material = material; }
public void restoreNewInstance() { newObj = Instantiate(prefab, sphereMovementScript.getStartPos(), Quaternion.identity); int oldPoints = sphereMovementScript.getPoints(); sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement; sphereMovementScript.setPoints(oldPoints); }
// Start is called before the first frame update protected override void Start() { base.Start(); input = GetComponent <SphereMovement>(); renderer = GetComponent <Renderer>(); audio = GetComponent <AudioSource>(); rb = GetComponent <Rigidbody>(); pc = GameObject.Find("PipeSystem").GetComponent <PipeColor>(); playedOnce = true; renderer.material.color = pc._scoreColor; input.enabled = false; rb.Sleep(); }
private void FixedUpdate() { sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement; }
// Start is called before the first frame update void Start() { startPos = transform.localPosition; sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement; }
// Start is called before the first frame update void Start() { sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement; prefab = Resources.Load("Prefabs/Sphere", typeof(GameObject)) as GameObject; newObj = GameObject.Find("Sphere"); }
// Start is called before the first frame update void Start() { sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement; }
private void Awake() { CrystalRenderer = Crystal.GetComponent <Renderer>(); Sphere = GameObject.FindGameObjectWithTag("Player"); SphereMovement = Sphere.GetComponent <SphereMovement>(); }
// Start is called before the first frame update void Start() { CollisionControl = FindObjectOfType <CollisionControl>(); sphere = FindObjectOfType <SphereMovement>(); }
private void FixedUpdate() { sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement; coins_text.text = "COINS: " + sphereMovementScript.getPoints(); }
// Start is called before the first frame update void Start() { sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement; coins_text = GetComponentInChildren <TMP_Text>(); }
// Start is called before the first frame update void Start() { sphereMovementScript = FindObjectOfType(typeof(SphereMovement)) as SphereMovement; prefab = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Sphere.prefab", typeof(GameObject)); newObj = GameObject.Find("Sphere"); }