private void Explode() { // detach rocket trail rocketTrail.Stop(); rocketTrail.transform.SetParent(null); Destroy(rocketTrail.gameObject, rocketTrail.duration); // freeze position rb.isKinematic = true; collided = true; // hide geometry foreach (Renderer r in GetComponentsInChildren <Renderer>()) { if (r != GetComponent <Renderer> ()) { r.enabled = false; } } // explode explosion.Play(); // damage and apply explosion force to objects // add gravity down vector to boost upward force on explosion Utilities.CreateExplosion(transform.position + GlobalGravityControl.GetCurrentGravityVector(), expRadius, expDamage, expForce); // destroy ui marker uiMarker.DestroyMarker(); // destroy after exploding Destroy(gameObject, explosion.duration); }
private void LogPlayerStats() { // print/log position velocity etc string playerDebugString = "Player: "; playerDebugString += "Pos " + player.transform.position + " "; playerDebugString += "Vel " + playerRb.velocity + " "; playerDebugString += "Spd " + playerRb.velocity.magnitude.ToString("F2") + " "; float localXZSpeed = Vector3.ProjectOnPlane(playerRb.velocity, GlobalGravityControl.GetCurrentGravityVector()).magnitude; float localYSpeed = Vector3.Project(playerRb.velocity, GlobalGravityControl.GetCurrentGravityVector()).magnitude; playerDebugString += "lclXZ " + localXZSpeed.ToString("F2") + " "; playerDebugString += "lclY " + localYSpeed.ToString("F2") + " "; playerDebugString += "Input: " + motor.GetInputVelocity(); //// dont print new line if identical to last line //if (playerDebugString == lastDebugString) // return; Debug.Log(playerDebugString); //lastDebugString = playerDebugString; }
/* * TODO: move or remove * * Try locking skybox and scene lighting to XZ orientation of the player * * - Could take this one step further * Rotate skybox and lighting at the same time as gravity, but in * a different (opposite?) direction. * * Get a cool light/shadow sweep effect when warping * Will need a slower warp for this effect though * * Puzzle elements!! * Other pieces of scenery that rotate when gravity shifts * paths that can only be accessed when gravity is in a particular direction? */ /* * Handles GravityChangeNotification, updates local current gravity variable */ void OnGravityChange(object sender, object args) { currentGravVector = GlobalGravityControl.GetCurrentGravityVector(); }
void OnGravityChangeNotification(object sender, object args) { currentGravVector = GlobalGravityControl.GetCurrentGravityVector(); currentGravRotation = GlobalGravityControl.GetGravityRotation(); }
// Update current gravity direction and strength void UpdateGravityValues() { currentGravityStrength = GlobalGravityControl.GetGravityStrength() * gravityModifier; currentGravityVector = GlobalGravityControl.GetCurrentGravityVector(); }