// Use this for initialization void Start() { Time.timeScale = 1; List <PlanetInfo> planets = GameState.LoadPlanets(); int count = 0; foreach (PlanetInfo pi in planets) { GameObject planet = (GameObject)Instantiate(menuPlanetPrefab, new Vector3(-2.5f + count * 1.5f, 1.35f, -7), Quaternion.identity); GameObject water = (GameObject)Instantiate(waterPrefab, new Vector3(-2.5f + count * 1.5f, 1.35f, -7), Quaternion.identity); water.transform.parent = planet.transform; water.transform.localScale *= .99f; water.name = "Water"; planet.AddComponent("MenuPlanet"); MenuPlanet mp = planet.GetComponent <MenuPlanet>(); mp.GeneratePlanet(width, height, pi, false); print("planet added"); count++; } pgThread = new PlanetGenerator(width, height); StartRandomPlanet(); roguePlanetObj = (GameObject)Instantiate(menuPlanetPrefab, new Vector3(0, .2f, -7), Quaternion.identity); GameObject rogueWater = (GameObject)Instantiate(waterPrefab, new Vector3(0, .2f, -7), Quaternion.identity); rogueWater.transform.parent = roguePlanetObj.transform; rogueWater.transform.localScale *= .99f; rogueWater.name = "Water"; roguePlanetObj.AddComponent("MenuPlanet"); rogueMP = roguePlanetObj.GetComponent <MenuPlanet>(); }
void generate() { Stopwatch sw = new Stopwatch(); sw.Start(); planetGeneratorData.seed = seed++; //planetGeneratorData.sphereDivisionLevel = seed++; var planet = PlanetGenerator.generate(planetGeneratorData); var compGround = GetComponent <MeshFilter>(); compGround.mesh = PlanetRenderer.createSurfaceMesh(planet); var compWater = transform.Find("Water").GetComponent <MeshFilter>(); compWater.mesh = PlanetRenderer.CreateWaterMesh(planet); var compRivers = transform.Find("Rivers").GetComponent <MeshFilter>(); compRivers.mesh = PlanetRenderer.CreateRiversMesh(planet); var transformStruct = transform.Find("Structures"); PlanetRenderer.CreateStructures(planet, transformStruct); m_planet = planet; sw.Stop(); UnityEngine.Debug.Log("Elapsed total " + sw.Elapsed); }
// Use this for initialization void Start() { if (SceneManager.GetActiveScene().name.Equals("Planet")) { pg = GameObject.FindGameObjectWithTag("grid").GetComponent <PlanetGenerator>(); } }
public void PrepNewLevel() { PlanetGenerator sb = new PlanetGenerator(); _planetsData.AddRange( sb.LoadPlanets(_rect, _startPosition, _minBodySize, _maxBodySize, _minGravityDepth, _maxGravityDepth, _minGapDist, _maxGapDist)); PrintPlanetData(); }
public static void StartGame(GameState providedGameState = default) { var effectiveGameState = providedGameState; if (effectiveGameState == default) { effectiveGameState = new GameState(); effectiveGameState.ConsumptionRates = consumptionRates; effectiveGameState.Ship = ShipGenerator.GenerateShip(ShipGenerator.ShipTypes[0]); //{ // ConsumptionRates = consumptionRates, // Ship = ShipGenerator.GenerateShip(ShipGenerator.ShipTypes[0]), // Options = new GameStateOptions() // { // AreAnimationsEnabled = true, // BackgroundVolume = 0.125f // } //}; effectiveGameState.Planets.AddRange(PlanetGenerator.GeneratePlanets(4)); effectiveGameState.CurrentScene = SceneNames.Far; } GameState = effectiveGameState; ChangeScene(effectiveGameState.CurrentScene); }
// Use this for initialization void Start() { Time.timeScale = 1; List<PlanetInfo> planets = GameState.LoadPlanets(); int count = 0; foreach (PlanetInfo pi in planets) { GameObject planet = (GameObject)Instantiate(menuPlanetPrefab, new Vector3(-2.5f + count * 1.5f, 1.35f, -7), Quaternion.identity); GameObject water = (GameObject)Instantiate(waterPrefab, new Vector3(-2.5f + count * 1.5f, 1.35f, -7), Quaternion.identity); water.transform.parent = planet.transform; water.transform.localScale *= .99f; water.name = "Water"; planet.AddComponent("MenuPlanet"); MenuPlanet mp = planet.GetComponent<MenuPlanet>(); mp.GeneratePlanet(width, height, pi,false); print("planet added"); count++; } pgThread = new PlanetGenerator(width, height); StartRandomPlanet(); roguePlanetObj = (GameObject)Instantiate(menuPlanetPrefab, new Vector3(0, .2f, -7), Quaternion.identity); GameObject rogueWater = (GameObject)Instantiate(waterPrefab, new Vector3(0, .2f, -7), Quaternion.identity); rogueWater.transform.parent = roguePlanetObj.transform; rogueWater.transform.localScale *= .99f; rogueWater.name = "Water"; roguePlanetObj.AddComponent("MenuPlanet"); rogueMP = roguePlanetObj.GetComponent<MenuPlanet>(); }
void spawnPlanets() { int numPlanets = Random.Range(minPlanets, maxPlanets); Vector2 basePos = GroundGenerator.me.transform.position; for (int i = 0; i < numPlanets; i++) { float rand1 = Random.Range(minDistance, maxDistance); if (Random.value > 0.5f) { rand1 *= -1; } float rand2 = Random.Range(minDistance, maxDistance); if (Random.value > 0.5f) { rand1 *= -1; } Vector2 randomPos = new Vector2(rand1, rand2); GameObject tempPlanet = Instantiate(planet, new Vector3(basePos.x + randomPos.x, basePos.x + randomPos.y, 0), Quaternion.identity); PlanetGenerator tempGen = tempPlanet.GetComponent <PlanetGenerator>(); tempGen.groundHeight = Random.Range(15, 30); tempGen.groundWidth = Random.Range(15, 30); //tempGen.frequency = Random.Range(0.7f, 1f); tempGen.spawnPlanet(); } }
void GeneratePlanets() { if (planets != null) { foreach (Planet p in planets) { Destroy(p.gameObject); } planets.Clear(); } PlanetGenerator generator = new PlanetGenerator(); planets = generator.GeneratePlanets(startMesh, amountOfPlanets, radius, noiseIntensity, noiseSmoothing, LOD); planets [0].Initialize(Vector3.zero, 20, 0); for (int i = 1; i < planets.Count; i++) { Planet p = planets [i]; //float speed = Random.Range (10, 20); Vector3 direction = (planets [0].transform.position - p.transform.position).normalized; Vector3 velocity = Quaternion.AngleAxis(90, Vector3.up) * direction /** speed*/; planets [i].Initialize(velocity, Random.Range(1, 5), i); } }
void Awake() { print("AWAKE"); instance = this; planetTex = new Texture2D(width, height, TextureFormat.ARGB32, false); pg = new PlanetGenerator(width, height, planetTex); }
void GetPlanets() { planets = new List <GameObject>(); PlanetGenerator.LoadPlanets(); Vector3 location = Vector3.zero; float r = 0f; for (int i = 0; i < numberOfPlanets; i++) { r = Random.Range(radius / 20, radius / 4); location.Set(r, location.y, -1f); planets.Add(Instantiate(PlanetGenerator.GetPlanet(), location, Quaternion.identity) as GameObject); planets[i].transform.SetParent(transform); planets[i].name = "Planet" + i; } planetRotations = new List <PlanetRotation>(); for (int i = 0; i < planets.Count; i++) { planetRotations.Add(planets[i].GetComponent <PlanetRotation>()); planetRotations[planetRotations.Count - 1].radius = planets[planetRotations.Count - 1].transform.position.x; planetRotations[planetRotations.Count - 1].theta = Random.Range(0, Mathf.PI * 2); planetRotations[planetRotations.Count - 1].speed = Random.Range(MIN_SPEED, MAX_SPEED); } }
// Use this for initialization void Start() { //Load up loading Overlay //Display loading Overlay //Set up Planet planet = new GameObject(); planet.name = STRING_PLANET; planet.tag = STRING_PLANET; PlanetGenerator planetIcosahedron = planet.AddComponent <PlanetGenerator>(); planetIcosahedron.Init(planet); //Set up Player Location //Set up Player Avatar //player = Instantiate(Resources.Load("Player")) as GameObject; player = Instantiate(playerPrefab) as GameObject; player.transform.position = planetIcosahedron.planetSurface; CharacterController playerController = player.AddComponent <CharacterController>(); playerController.radius = 15; playerController.height = 40; playerController.center = new Vector3(0, 20, 0); Movement playerMovement = player.AddComponent <Movement>(); PlayerController controller = player.AddComponent <PlayerController>(); controller.Init(); //Hide loading Overlay }
private void GeneratePlanet(int width, int height) { Texture2D planetTex = new Texture2D(width, height, TextureFormat.ARGB32, false); Texture2D cloudsTex = new Texture2D(width, height, TextureFormat.ARGB32, false); if (pg == null) { pg = new PlanetGenerator(width, height, true); } pg.generatePlanet(planetInfo); cloudsTex.SetPixels(pg.GetCloudColors()); cloudsTex.Apply(); GameObject clouds = GameObject.Find("Clouds"); if (clouds != null) { clouds.renderer.material.mainTexture = cloudsTex; } SetWater(planetInfo.colorRamp.gradient [0]); planetTex.SetPixels(pg.GetPlanetColors()); planetTex.Apply(); renderer.material.mainTexture = planetTex; pg.Finished(); }
static void Main(string[] args) { Map gameMap = new Map(); foreach (var item in Map.arr2d) { Console.WriteLine(item.ToString()); } Map.ConsoleMap(); Planet planetOne = PlanetGenerator.GetPlanet(); Console.WriteLine(planetOne.AnimalType); Console.WriteLine(planetOne.WaterType); Console.WriteLine(planetOne.LifeType); Console.WriteLine(planetOne.AtmosphereType); Planet newPlanetTwo = PlanetGenerator.GetPlanet(); Console.WriteLine(newPlanetTwo.AnimalType); Console.WriteLine(newPlanetTwo.WaterType); Console.WriteLine(newPlanetTwo.LifeType); Console.WriteLine(newPlanetTwo.AtmosphereType); }
private async Task GenerateTurnsAsync() { await Task.Run(() => { var planetGenerator = new PlanetGenerator(this.PlanetTypes); var planetCounter = 0; var planetsPerTurn = this.PlanetsPerTurn; for (int turnCounter = 0; turnCounter < this.AmountToGenerate; turnCounter++) { var turn = new Turn() { Number = turnCounter + 1 }; foreach (var planet in planetGenerator.Generate(planetsPerTurn)) { turn.Planets.Add(planet); planetCounter++; this.StatisticsContext.AddPlanet(planet); } System.Windows.Application.Current.Dispatcher.Invoke(() => { this.GeneratedTurns.Add(turn); }); } }); }
public void Generate(GameObject System) { Random.seed = randomSeed; int twinSun = 1;//Random.Range(0,1); planets = new PlanetGenerator[5]; for (int i = 0; i < planets.Length; i++) { planets[i] = new PlanetGenerator(); planets[i].randomSeed = (int)Random.Range(int.MinValue, int.MaxValue); } float minRange = 0.0f; float maxRange = 2.0f; PlanetGenerator sunGenerator = new PlanetGenerator(); if (twinSun == 1) { minRange += sunGenerator.GenerateTwinSun(System); maxRange = minRange + 2.0f; } else { minRange += sunGenerator.GenerateSun(System); maxRange = minRange + 2.0f; } for (int i = 0; i < planets.Length; i++) { minRange += planets[i].Generate(System, minRange, maxRange); maxRange = minRange + 2.0f; } }
PlanetGenerator FindClosestPlanet() { if(_planet == null) { _planet = FindObjectOfType<PlanetGenerator>(); } return _planet; }
PlanetGenerator FindClosestPlanet() { if (_planet == null) { _planet = FindObjectOfType <PlanetGenerator>(); } return(_planet); }
//int planetNameIndex = 0; // index into the planet Names. //NOTE: using spawnedItems.Count instead // Use this for initialization void Start() { ParentStart(); itemsToSpawn = Random.Range (minNumPlanets, maxNumPlanets); planetGenerator = PlanetGeneratorPrefab.GetComponent<PlanetGenerator> (); planetNameGenerator = this.GetComponent<PlanetNameGenerator2>(); planetNames = planetNameGenerator.GetSolarSystemNames(itemsToSpawn); //generate a list of names to use for the planets }
public static PlanetGenerator getInstance() { if (Instance == null) { Instance = new PlanetGenerator(); } return(Instance); }
// Use this for initialization void Start() { spaces = GetComponentInParent <PlanetGenerator> ().spaces; planetgen = GetComponentInParent <PlanetGenerator> (); limit = Random.Range(2, 5); identity = seed.idenLoc; Settings(); }
public void New() { PlanetGenerator.getInstance().Generate(); if (PlanetGenerator.getInstance().isLoad) { PlanetGenerator.getInstance().Save(); } }
public frmConfig(PlanetGenerator generator) { InitializeComponent(); _generator = generator; _allItems = new List <ListViewItem>(); _programVersion = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location); this.Text = "PlanetGenerator Reborn " + _programVersion.FileVersion + " by Marc D."; }
//Adjusts the render order of the planets so they are in the correct order when the prince is flying void adjustRenderOrderForPrincePos() { GetComponent <SpriteRenderer> ().sortingOrder = -((int)(transform.position.z - princeTransform.position.z) % 2000) * 5;; PlanetGenerator generatorScript = GameObject.FindGameObjectWithTag("Planet").GetComponent <PlanetGenerator> (); for (int i = 0; i < transform.childCount; i++) { generatorScript.setChildRenderOrder(GetComponent <SpriteRenderer> ().sortingOrder, transform.GetChild(i).GetComponent <SpriteRenderer> (), i); } }
void Start() { generator = GetComponent <PlanetGenerator>(); generator.Create(); generator.SetBaseColor(baseColor); // text = FindObjectOfType<Text>(); StartCoroutine("Terraform", iterations); }
public GameObject Genererate(PlanetGenerator generator, Vector3 floorPosition, Quaternion boxOrientation, Vector3 forwardWS, Vector3 upWS, Vector3 rightWS) { float randomNumber = _perlinNoiseGenerator.Generate(floorPosition * _moiseScale); if (randomNumber > _treeProbability) { return(null); } _generator = generator; _floorPosition = floorPosition; _boxOrientation = boxOrientation; _inverseBoxOrientation = Quaternion.Inverse(_boxOrientation); _forwardWS = forwardWS * _lengthXZFactor; _upWS = upWS * _lengthYFactor; _rightWS = rightWS * _lengthXZFactor; _forward = _inverseBoxOrientation * _forwardWS; _up = _inverseBoxOrientation * _upWS; _right = _inverseBoxOrientation * _rightWS; Vector3 floorPivotPos = _floorPosition - rightWS * 0.5f - _forwardWS * 0.5f; // Trunk DoGenererateBox(floorPivotPos); DoGenererateBox(floorPivotPos + _upWS); DoGenererateBox(floorPivotPos + _upWS - _forwardWS * 2f - _rightWS); DoGenererateBox(floorPivotPos + _upWS - _forwardWS * 2f); DoGenererateBox(floorPivotPos + _upWS - _forwardWS * 2f + _rightWS); DoGenererateBox(floorPivotPos + _upWS + _forwardWS * 2f - _rightWS); DoGenererateBox(floorPivotPos + _upWS + _forwardWS * 2f); DoGenererateBox(floorPivotPos + _upWS + _forwardWS * 2f + _rightWS); DoGenererateBox(floorPivotPos + _upWS - _forwardWS - _rightWS * 2f); DoGenererateBox(floorPivotPos + _upWS - _rightWS * 2f); DoGenererateBox(floorPivotPos + _upWS + _forwardWS - _rightWS * 2f); DoGenererateBox(floorPivotPos + _upWS - _forwardWS + _rightWS * 2f); DoGenererateBox(floorPivotPos + _upWS + _rightWS * 2f); DoGenererateBox(floorPivotPos + _upWS + _forwardWS + _rightWS * 2f); DoGenererateBox(floorPivotPos + _upWS * 2f); DoGenererateBox(floorPivotPos + _upWS * 2f - _forwardWS); DoGenererateBox(floorPivotPos + _upWS * 2f + _forwardWS); DoGenererateBox(floorPivotPos + _upWS * 2f - _rightWS); DoGenererateBox(floorPivotPos + _upWS * 2f + _rightWS); return(null); }
// populate this planet with rocks public void Initialize(PlanetGenerator planetGenerator, float elevationScale, int randomSeed) { // get to this planet var planet = planetGenerator.GetPlanet(); // calculate the number of rocks to place var numRocks = (planet.m_mineralDensity * m_maxNumRocks) / 100; // place them Initialize(elevationScale, m_rockTemplates, numRocks, randomSeed, true, 1.0f, 1.0f); }
void Start() { Light sunLight = this.GetComponent <Light> (); sunLight.range = 20; sunLight.intensity = 800; grid = GameObject.FindGameObjectWithTag("FrontGround").transform.parent; //scriptGen = grid.GetComponent<GroundGenerator> (); scriptGen = grid.GetComponent <PlanetGenerator> (); }
public void StartGenerate(int subdivisions) { this.pg = new PlanetGenerator(); this.isGenerated = false; // this.progressLabel = (Label)GetNode("DefaultScene/LoadingScreen/Root/MainLayout/Inner/LoadingLayout/CurrentStatus"); // FindN System.Threading.Thread t = new System.Threading.Thread(() => GenerateSphere(subdivisions)); t.Start(); }
public override void OnInspectorGUI() { PlanetGenerator planetGenmerator = (PlanetGenerator)target; base.OnInspectorGUI(); GUILayout.Space(20); if (GUILayout.Button("Reconstruct")) { planetGenmerator.CreatePlanet(); } }
void Start() { Planet = PlanetGenerator.Generate(Radius, TerrainHeight); Mass = Planet.Mass; LoadedChunks = new Dictionary <Chunk, GameObject>(); ChunkQueue = new PriorityQueue <Chunk>(); RegionLoader = LoadRegions(); StartCoroutine(RegionLoader); }
/* parameters: * seed of the planet, min/max radius of planet, min/max variance of the surface, min/max number of points on the planet. * returns: * new Planet object * description: does all the math to make the planet, stores the representation of the planet by altering 'points' and 'connections'. */ public Planet(System.Random r, float minRad, float maxRad, float minVariance, float maxVariance, int latPoints, int longPoints) { this.r = r; //get random values from the seed radius = (float)(r.NextDouble() * (maxRad - minRad) + minRad); variance = (float)(r.NextDouble() * (maxVariance - minVariance) + minVariance); int varianceSeed = r.Next(int.MinValue, int.MaxValue); //make the planet, store results in points and connections. PlanetGenerator.MakePlanet(radius, variance, r, latPoints, longPoints, out points, out connections); }
// populate this planet with trees public void Initialize(PlanetGenerator planetGenerator, float elevationScale, int randomSeed) { // get to this planet var planet = planetGenerator.GetPlanet(); // calculate the number of trees to place var numTrees = (planet.m_bioDensity * m_maxNumTrees) / 100; // place them Initialize(elevationScale, m_treeTemplates, numTrees, randomSeed, false, 0.67f, 1.0f); }
private void Initialize() { var planetMesh = PlanetGenerator.Generate(resolution); _meshFilter.mesh.Clear(); _meshFilter.mesh = planetMesh; _meshCollider.sharedMesh = planetMesh; Tiles = PlanetGenerator.GetTiles(_meshFilter.sharedMesh); Radius = (_meshFilter.sharedMesh.vertices[0] - transform.position).magnitude; }
public void Start() { if (id != -1) { return; } this.entities = new List <PlanetEntity>(); this.lowElectricityQueue = new Stack <PlanetEntity>(); this.lowPopulationQueue = new Stack <PlanetEntity>(); this.generator = this.GetComponent <PlanetGenerator>(); id = ids++; }
public GameObject Genererate(PlanetGenerator generator, Vector3 floorPosition, Quaternion boxOrientation, Vector3 forwardWS, Vector3 upWS, Vector3 rightWS) { float randomNumber = _perlinNoiseGenerator.Generate(floorPosition * _moiseScale); if(randomNumber > _treeProbability) { return null; } _generator = generator; _floorPosition = floorPosition; _boxOrientation = boxOrientation; _inverseBoxOrientation = Quaternion.Inverse(_boxOrientation); _forwardWS = forwardWS * _lengthXZFactor; _upWS = upWS * _lengthYFactor; _rightWS = rightWS * _lengthXZFactor; _forward = _inverseBoxOrientation * _forwardWS; _up = _inverseBoxOrientation * _upWS; _right = _inverseBoxOrientation * _rightWS; Vector3 floorPivotPos = _floorPosition -rightWS*0.5f -_forwardWS*0.5f; // Trunk DoGenererateBox(floorPivotPos); DoGenererateBox(floorPivotPos+_upWS); DoGenererateBox(floorPivotPos+_upWS -_forwardWS*2f -_rightWS); DoGenererateBox(floorPivotPos+_upWS -_forwardWS*2f); DoGenererateBox(floorPivotPos+_upWS -_forwardWS*2f +_rightWS); DoGenererateBox(floorPivotPos+_upWS +_forwardWS*2f -_rightWS); DoGenererateBox(floorPivotPos+_upWS +_forwardWS*2f); DoGenererateBox(floorPivotPos+_upWS +_forwardWS*2f +_rightWS); DoGenererateBox(floorPivotPos+_upWS -_forwardWS -_rightWS*2f); DoGenererateBox(floorPivotPos+_upWS -_rightWS*2f); DoGenererateBox(floorPivotPos+_upWS +_forwardWS -_rightWS*2f); DoGenererateBox(floorPivotPos+_upWS -_forwardWS +_rightWS*2f); DoGenererateBox(floorPivotPos+_upWS +_rightWS*2f); DoGenererateBox(floorPivotPos+_upWS +_forwardWS +_rightWS*2f); DoGenererateBox(floorPivotPos+_upWS*2f); DoGenererateBox(floorPivotPos+_upWS*2f -_forwardWS); DoGenererateBox(floorPivotPos+_upWS*2f +_forwardWS); DoGenererateBox(floorPivotPos+_upWS*2f -_rightWS); DoGenererateBox(floorPivotPos+_upWS*2f +_rightWS); return null; }
void GeneratePlanets () { if (planets != null) { foreach (Planet p in planets) { Destroy (p.gameObject); } planets.Clear (); } PlanetGenerator generator = new PlanetGenerator (); planets = generator.GeneratePlanets (startMesh, amountOfPlanets, radius, noiseIntensity, noiseSmoothing, LOD); planets [0].Initialize (Vector3.zero, 20, 0); for (int i = 1; i < planets.Count; i++) { Planet p = planets [i]; //float speed = Random.Range (10, 20); Vector3 direction = (planets [0].transform.position - p.transform.position).normalized; Vector3 velocity = Quaternion.AngleAxis (90, Vector3.up) * direction /** speed*/; planets [i].Initialize (velocity, Random.Range (1, 5), i); } }
public void Init(Transform host, PlanetGenerator planet, SphericalPhysics physics) { _host = host; _planet = planet; _physics = physics; }
public void Init(PlanetGenerator planet) { _panet = planet; }
public void SetGenerationProperties(PlanetGenerator.BoxGenerationProperties generationProperties) { _generationProperties = generationProperties; }
void Init() { _planet = FindClosestPlanet(); _mover.Init(transform, _planet, _physics); }
private void GeneratePlanet(int width, int height) { Texture2D planetTex = new Texture2D (width, height, TextureFormat.ARGB32, false); Texture2D cloudsTex = new Texture2D (width, height, TextureFormat.ARGB32, false); if (pg == null) { pg = new PlanetGenerator (width, height, true); } pg.generatePlanet (planetInfo); cloudsTex.SetPixels (pg.GetCloudColors ()); cloudsTex.Apply (); GameObject clouds = GameObject.Find ("Clouds"); if (clouds != null) clouds.renderer.material.mainTexture = cloudsTex; SetWater (planetInfo.colorRamp.gradient [0]); planetTex.SetPixels (pg.GetPlanetColors ()); planetTex.Apply (); renderer.material.mainTexture = planetTex; pg.Finished (); }
// Use this for initialization void Start() { generator = GameObject.Find("PlanetGenerator").GetComponent<PlanetGenerator>(); }
void Update() { _planet = FindClosestPlanet(); Vector3 localPosition = _planet.ConvertToLocalPosition(_host.position); float dt = Time.deltaTime; Vector3 deltaPosition = _currentVelocity * dt; deltaPosition += _planet.GetGravity(localPosition) * _gravityFactor * dt; Vector3 targetLocalPosition = localPosition + deltaPosition; //CheckCollisions(_host.transform.position, deltaPosition, ref targetLocalPosition, ref _currentVelocity); Vector3 fixedPosition; if(SetOverTheSuface(targetLocalPosition, out fixedPosition)) { Vector3 diff = fixedPosition - localPosition; Vector3 forwardDelta = Vector3.Dot(diff, _host.forward) * _host.forward; Vector3 rightDelta = Vector3.Dot(diff, _host.right) * _host.right; Vector3 upDelta = Vector3.Dot(diff, _host.up) * _host.up; upDelta = Vector3.Slerp(Vector3.zero, upDelta, Time.deltaTime * 16f); Vector3 nextPosition = localPosition + forwardDelta + rightDelta + upDelta; _host.transform.position = nextPosition; } else { _host.transform.position = _planet.ConvertToWorldPosition(targetLocalPosition); } UpdateOrientation(); ApplyDrag(); }
void Awake() { print ("AWAKE"); instance = this; planetTex = new Texture2D (width, height, TextureFormat.ARGB32, false); pg = new PlanetGenerator (width, height, planetTex); }