private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Planet") { attractor = collision.gameObject.GetComponent <GravityAttractor>(); } }
public void SetAttractor(GravityAttractor _attractor) { if ((_attractor != null && !canLeave) || canLeave) { attractor = _attractor; } }
void Start() { this.planet = Player.Instance.getPlanetNavigation().GetComponent<GravityAttractor>(); this.rb = this.GetComponent<Rigidbody>(); this.rb.useGravity = false; }
void Awake() { planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <GravityAttractor>(); GetComponent <Rigidbody>().useGravity = false; GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation; //don't want rigid bodies to do its own rotation }
void OnTriggerExit(Collider col) { if (col.gameObject.tag == "Planet" && !beingControlled) { planet = null; } }
//disabling all the nesasary rigidbody components to allow it to move on its own void Awake() { planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <GravityAttractor>(); rigidbody = GetComponent <Rigidbody>(); rigidbody.useGravity = false; rigidbody.constraints = RigidbodyConstraints.FreezeRotation; }
void OnTriggerExit(Collider col) { if (col.CompareTag("Planet")) { attractor = null; } }
void SpawnAttractor() { GravityAttractor prefab = attractorPrefabs[Random.Range(0, attractorPrefabs.Length)]; GravityAttractor spawn = Instantiate <GravityAttractor>(prefab); spawn.transform.localPosition = Random.onUnitSphere * spawnDistance; }
void Awake () { currentGravityObject = GameObject.FindGameObjectWithTag("StartingGravityPoint").GetComponent<GravityAttractor>(); rigidbody = GetComponent<Rigidbody> (); rigidbody.useGravity = false; rigidbody.constraints = RigidbodyConstraints.FreezeRotation; }
private void Awake() { _planet = GameObject.FindGameObjectWithTag("World").GetComponent <GravityAttractor>(); _rb = GetComponent <Rigidbody>(); _rb.useGravity = false; _rb.constraints = RigidbodyConstraints.FreezeRotation; }
void Start() { this.planet = Player.Instance.getPlanetNavigation().GetComponent <GravityAttractor>(); this.rb = this.GetComponent <Rigidbody>(); this.rb.useGravity = false; }
//FixedUpdate gets called at a regular interval independent from the framerate void FixedUpdate() { if (planetGravity) { targetGravity = targetPlanet.GetComponent <GravityAttractor> (); targetGravity.Attract(transform); } else { // Apply downwards gravity to body transform.GetComponent <Rigidbody> ().AddForce(gravityUp * gravity); // Allign bodies up axis with the centre of planet Quaternion targetRotation = Quaternion.FromToRotation(transform.up, gravityUp) * transform.rotation; float angularSpeed = 3.0f; if (transform.rotation != targetRotation) { //transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, angularSpeed); transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, angularSpeed); //print("Player: " + transform.rotation + ", target: " + targetRotation); //transform.Rotate(0, yAmount, 0, Space.Self); } } //linear interpolation //Zielposition über Zeitraum }
void Awake() { planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <GravityAttractor>(); // Disable rigidbody gravity and rotation as this is simulated in GravityAttractor script rigidbody.useGravity = false; rigidbody.constraints = RigidbodyConstraints.FreezeRotation; }
void Awake() { currentGravityObject = GameObject.FindGameObjectWithTag("StartingGravityPoint").GetComponent <GravityAttractor>(); rigidbody = GetComponent <Rigidbody> (); rigidbody.useGravity = false; rigidbody.constraints = RigidbodyConstraints.FreezeRotation; }
void Awake () { planet = GameObject.FindGameObjectWithTag("Planet").GetComponent<GravityAttractor>(); rigidbody = GetComponent<Rigidbody> (); // Disable rigidbody gravity and rotation as this is simulated in GravityAttractor script rigidbody.useGravity = false; rigidbody.constraints = RigidbodyConstraints.FreezeRotation; }
void Awake() { thisRigidBody = GetComponent <Rigidbody> (); thisRigidBody.useGravity = false; thisRigidBody.constraints = RigidbodyConstraints.FreezeRotation; planet = GetComponentInParent <GravityAttractor> (); }
void Start() { planet_script_ = planet_.GetComponent <GravityAttractor>(); controller_script_ = GetComponent <PlayerSphericalGravityController>(); rigidbody_ = GetComponent <Rigidbody>(); rigidbody_.useGravity = false; rigidbody_.constraints = RigidbodyConstraints.FreezeRotation; }
private void Awake() { attractor = GameObject.FindGameObjectWithTag("Attractor").GetComponent <GravityAttractor>(); body = GetComponent <Rigidbody>(); body.useGravity = false; body.constraints = RigidbodyConstraints.FreezeRotation; }
void Start() { attractor = FindObjectOfType <GravityAttractor> (); GetComponent <Rigidbody>().useGravity = false; GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation; myTransform = transform; }
void Awake() { planet = GameObject.FindGameObjectWithTag("Planet").GetComponent<GravityAttractor>(); if (GetComponent<Rigidbody2D>()) { GetComponent<Rigidbody2D>().gravityScale = 0; GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation; } }
void Awake() { attractor = GameObject.FindGameObjectWithTag("Attractor").GetComponentInChildren <GravityAttractor>(); rb = GetComponent <Rigidbody>(); // Disable rigidbody gravity and rotation as this is simulated in GravityAttractor script rb.constraints = RigidbodyConstraints.FreezeRotation; rb.useGravity = false; }
private void WallDetect() { RaycastHit objectHit; //Up if (Physics.Raycast(transform.position, transform.up, out objectHit, 0.5f)) { if (objectHit.transform.tag == "Wall") { gravityAttractor = objectHit.transform.GetComponent <GravityAttractor>(); } } //Forward else if (Physics.Raycast(transform.position, transform.forward, out objectHit, wallDetection)) { if (objectHit.transform.tag == "Wall") { gravityAttractor = objectHit.transform.GetComponent <GravityAttractor>(); } } //Right else if (Physics.Raycast(transform.position, transform.right, out objectHit, wallDetection)) { if (objectHit.transform.tag == "Wall") { gravityAttractor = objectHit.transform.GetComponent <GravityAttractor>(); } } //Back else if (Physics.Raycast(transform.position, -transform.forward, out objectHit, wallDetection)) { if (objectHit.transform.tag == "Wall") { gravityAttractor = objectHit.transform.GetComponent <GravityAttractor>(); } } //Left else if (Physics.Raycast(transform.position, -transform.right, out objectHit, wallDetection)) { if (objectHit.transform.tag == "Wall") { gravityAttractor = objectHit.transform.GetComponent <GravityAttractor>(); } } //Down else if (Physics.Raycast(transform.position, -transform.up, out objectHit, wallDetection)) { if (objectHit.transform.tag == "Wall") { gravityAttractor = objectHit.transform.GetComponent <GravityAttractor>(); } } }
void Start() { _body = GetComponent <Rigidbody>(); if (attractor == null) { attractor = GameObject.FindGameObjectWithTag("Attractor").GetComponent <GravityAttractor>(); } }
void Awake() { centerSphere = GameObject.FindGameObjectWithTag("CenterSphere").GetComponent <GravityAttractor>(); rigidBody = GetComponent <Rigidbody>(); t = GetComponent <Transform>(); rigidBody.useGravity = false; rigidBody.constraints = RigidbodyConstraints.FreezeRotation; }
void OnTriggerEnter(Collider col) { GravityAttractor obj = col.GetComponent("GravityAttractor") as GravityAttractor; if (obj) { attractor = obj; } }
void Start() { gravityAttractor = GetComponent<GravityAttractor> (); sphereCollider = GetComponent<SphereCollider> (); hideFrontPlanetFaceOnEnter = GetComponentInChildren<HideFrontPlanetFaceOnEnter> (); if(hideFrontPlanetFaceOnEnter!=null){ hasInsidePlanet = true; } initialize (); }
public void ChangePlanetAttractedTo() { GameObject newPlanet = GameController.instance.planets[FindClosestPlanet()]; if (planetAttractedTo != newPlanet) { planetAttractedTo = newPlanet; planetScript = planetAttractedTo.GetComponent <GravityAttractor>(); } }
private void Awake() { settings = FindObjectOfType <GameSettings>(); planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <GravityAttractor>(); rb = GetComponent <Rigidbody>(); rb.useGravity = false; rb.constraints = RigidbodyConstraints.FreezeRotation; }
void Awake () { planet = GameObject.FindGameObjectWithTag("Planet").GetComponent<GravityAttractor>(); rigidbody = GetComponent<Rigidbody2D> (); // Disable rigidbody gravity and rotation as this is simulated in GravityAttractor script rigidbody.gravityScale = 0; rigidbody.fixedAngle = true; gravityCentre = planet.transform.position; }
void Start() { gravityAttractor = GetComponent <GravityAttractor> (); sphereCollider = GetComponent <SphereCollider> (); hideFrontPlanetFaceOnEnter = GetComponentInChildren <HideFrontPlanetFaceOnEnter> (); if (hideFrontPlanetFaceOnEnter != null) { hasInsidePlanet = true; } initialize(); }
void Awake() { planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <GravityAttractor>(); rigidbody = GetComponent <Rigidbody2D> (); // Disable rigidbody gravity and rotation as this is simulated in GravityAttractor script rigidbody.gravityScale = 0; rigidbody.fixedAngle = true; gravityCentre = planet.transform.position; }
void Awake() { GameObject planet = GameObject.FindGameObjectWithTag(Tags.Planet); attractor = planet.GetComponent <GravityAttractor>(); Rigidbody rigidBody = GetComponent <Rigidbody>(); rigidBody.useGravity = false; rigidBody.constraints = RigidbodyConstraints.FreezeRotation; }
void Awake() { // Get the planet object if i tag it with planet planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <GravityAttractor>(); rb = GetComponent <Rigidbody>(); // Disable normal gravity and use the gravity created with my code rb.useGravity = false; // Makes the body not rotate normally only make it change if i tell it to rb.constraints = RigidbodyConstraints.FreezeRotation; }
void Awake() { //Started to use tags, they are the best. planet = GameObject.FindGameObjectWithTag("Planet").GetComponent <GravityAttractor>(); rigidbody = GetComponent <Rigidbody> (); // We have our own gravity...kind of the whole point. Disabling the in built gravity is required. rigidbody.useGravity = false; //Same as before, we want to do our own rotation. rigidbody.constraints = RigidbodyConstraints.FreezeRotation; }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Planet" && !beingControlled) { planet = col.gameObject.GetComponent <GravityAttractor> (); if (this.gameObject.layer == 8) { //this.transform.SetParent (col.transform); } } }
private void Awake() { m_Transform = GetComponent <Transform>(); m_Rigidbody = GetComponent <Rigidbody>(); m_CenterSphere = GameObject.FindGameObjectWithTag("CenterSphere").GetComponent <GravityAttractor>(); m_GameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); m_Camera = m_Transform.Find("Camera").gameObject.GetComponent <CameraController>(); m_RadarCamera = m_Transform.Find("RadarCamera").gameObject.GetComponent <CameraController>(); m_StatusEffect["Slow"] = 0.0f; m_Rigidbody.useGravity = false; m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotation; m_PowerUpSlot = null; }
void SetClosestAttractor() { if (attractors == null || attractors.Length < 1) { return; } GravityAttractor closestAttractor = attractors[0]; for (int i = 1; i < attractors.Length; i++) { Vector3 curPosition = gameObject.transform.position; float curDistance = Vector3.Distance(curPosition, closestAttractor.transform.position); float tempDistance = Vector3.Distance(curPosition, attractors[i].transform.position); if (tempDistance < curDistance) { closestAttractor = attractors[i]; } } curAttractor = closestAttractor; }
public void SetPlanetGravity(GravityAttractor _planetGravity) { planetGravity = _planetGravity; }
/** * Finds the first attractor within this object. */ void Awake() { attractor = GetComponentInChildren<GravityAttractor>(); }
// Quick implementation of the gravity law, because we're awesome. private Vector3 Attraction(GravityAttractor attractor) { Vector3 r = myBody.position - attractor.transform.position; Vector3 result = ((reasonableG * myBody.mass * attractor.mass) / Mathf.Pow(r.magnitude, 2f)) * r.normalized; return result; }
void Awake() { planet = GameObject.FindGameObjectWithTag("Planet").GetComponent<GravityAttractor>(); }
public void GetAttracted(GravityAttractor newPlanet) { planet = newPlanet; }