示例#1
0
    public void CreateObstacle()
    {
        float min = MyPlayer.GetChild(1).position.x - CurrentLevel.Range;
        float max = MyPlayer.GetChild(1).position.x + CurrentLevel.Range;

        Vector3  _NewPos    = new Vector3(Random.Range(min, max), MyPlayer.GetChild(1).position.y, MyPlayer.GetChild(1).position.z);
        Obstacle _obstacle1 = Instantiate(MyObstacles, _NewPos, Quaternion.identity);

        _obstacle1.TimeDestroyObstacle = CurrentLevel.TimeDestroy;
        _obstacle1.transform.SetParent(ObstacleParent);

        Obstacle _obstacle2 = Instantiate(MyObstacles, ObstacleParent.position, Quaternion.identity);

        _obstacle2.RandomPostion       = true;
        _obstacle2.TimeDestroyObstacle = CurrentLevel.TimeDestroy;
        _obstacle2.transform.SetParent(ObstacleParent);
        Count = 0;
    }