// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D>(); rb.constraints = RigidbodyConstraints2D.FreezeRotation; attractor = FauxGravityAttractor.Instance; }
// Start is called before the first frame update void Awake() { attractor = GameObject.FindGameObjectWithTag("World").GetComponent <FauxGravityAttractor>(); GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation; GetComponent <Rigidbody>().useGravity = false; myTransform = transform; }
void Start() { rb = GetComponent<Rigidbody>(); rb.constraints = RigidbodyConstraints.FreezeRotation; rb.useGravity = false; attractor = GameObject.Find("Planet").GetComponent<FauxGravityAttractor>(); }
// Start is called before the first frame update void Start() { attractor = GameObject.Find("World").GetComponent <FauxGravityAttractor>(); myTransform = transform; _rb.constraints = RigidbodyConstraints2D.FreezeRotation; _rb.gravityScale = 0; }
private void Start() { GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation; GetComponent <Rigidbody>().useGravity = false; attractor = GameObject.Find("Planet").GetComponent <FauxGravityAttractor>(); }
private void OnTriggerEnter(Collider other) { if (other.tag == "Swap") { attractor = other.GetComponentInParent <FauxGravityAttractor>(); Debug.Log("Swapped"); } }
// Use this for initialization void Start() { rb = gameObject.GetComponent <Rigidbody>(); rb.constraints = RigidbodyConstraints.FreezeRotation; rb.useGravity = false; whatev = gameObject.transform; attractor = GameObject.FindWithTag("Planet").GetComponent <FauxGravityAttractor>(); }
//had to manually select the celestial body gameobject because an instantiated prefab (the bullets) needs to use this script. //Can't just drag it into a prefab unfortuantely. void Start() { //now uses the world tag to find him. Map = GameObject.FindGameObjectWithTag("World"); rigidbody.useGravity = false; rigidbody.constraints = RigidbodyConstraints.FreezeRotation; attractor = (FauxGravityAttractor)Map.GetComponent(typeof(FauxGravityAttractor)); myTransform = transform; }
void Start() { rigidBody = GetComponent <Rigidbody>(); attractor = FindObjectOfType <FauxGravityAttractor>(); // rotation and the gravity are controlled by the Attract() in FausGravityAttractor.cs rigidBody.constraints = RigidbodyConstraints.FreezeRotation; rigidBody.useGravity = false; }
/// <summary> // Start is called before the first frame update /// </summary> void Start() { // get the only instance of attractor fauxGravityAttractor = FauxGravityAttractor.instance; // setup the rigidbody consraints rb = this.GetComponent <Rigidbody>(); rb.constraints = RigidbodyConstraints.FreezeRotation; rb.useGravity = false; }
// Update is called once per frame void Update() { if (Application.loadedLevelName == "Scene" || Application.loadedLevelName == "Tutorial") { attractor = GameObject.Find("Planet").GetComponent<FauxGravityAttractor>(); this.GetComponent<Rigidbody>().useGravity = false; attractor.attract (myTransform); } else { this.GetComponent<Rigidbody>().useGravity = true; } }
IEnumerator Gravity(float time) { yield return(new WaitForSeconds(time)); attracter = GameObject.FindGameObjectWithTag("Attracter").GetComponent <FauxGravityAttractor>(); rb = GetComponent <Rigidbody>(); rb.constraints = RigidbodyConstraints.FreezeRotation; rb.useGravity = false; myTransform = transform; canAttract = true; }
private void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); } else { Instance = this; } }
void Start() { CurrentGravityBody = this.GetComponent <FauxGravityBody>(); CurrentGravityAttractor = CurrentGravityBody.attractor; rb = this.GetComponent <Rigidbody>(); PlayerAnimController = PlayerModel.GetComponent <AnimController>(); currentMoveDirection = Direction.still; CurrentSpeedMovement = SpeedMovement.Idle; rb.useGravity = false; // Disables Gravity rb.constraints = RigidbodyConstraints.FreezeRotation; // controller sided; }
void Start() { GetComponent <Rigidbody>().useGravity = false; GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation; myTransform = transform; if (useMultiAttractor) { _attractor.Add(starting_attractor.gameObject); } else { attractor = starting_attractor; } }
// Update is called once per frame void Update() { objs = GameObject.FindGameObjectsWithTag("Gravity"); if (objs.Length != inattractor.Length) { GatherAttractors(); } for (int i = 0; i < inattractor.Length; i++) { if(inattractor[i] != null) { attractor = inattractor[i]; } attractor.Attract(myTransform); } }
void Start() { if (attractor == null) { GameObject player = GameObject.FindGameObjectWithTag("Player"); attractor = player.GetComponent <FauxGravityAttractor>(); } GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation; GetComponent <Rigidbody>().useGravity = false; myTransform = transform; if (alwaysFacing) { facingDirection = facingDirection.normalized; } }
void Start() { // Get Attractor component from Planet if (attractor == null) { attractor = GameObject.FindWithTag("Planet").GetComponent <FauxGravityAttractor>(); } // Get rigid body component reference Rigidbody rb = GetComponent <Rigidbody>(); rb.constraints = RigidbodyConstraints.FreezeRotation; // Disable Rotation rb.useGravity = false; // Disable Gravity // Get transform reference myTransform = transform; }
// Start is called before the first frame update void Start() { attractor = FindObjectOfType <FauxGravityAttractor>(); rb = gameObject.GetComponent <Rigidbody>(); if (lockedRotation) { rb.constraints = RigidbodyConstraints.FreezeRotation; } if (attractor) { rb.useGravity = false; } else { rb.useGravity = true; } myTransform = transform; }
void OnTriggerEnter(Collider collision) { if (collision.GetComponent <Collider> ().GetComponent <FauxGravityAttractor> () != null) { if (attractor != null) { attractor = null; } if (transform.parent != null) { transform.parent = null; } if (useMultiAttractor) { _attractor.Add(collision.GetComponent <Collider> ().gameObject); } else { attractor = collision.GetComponent <Collider> ().GetComponent <FauxGravityAttractor> (); } } }
private void FixedUpdate() { FauxGravityAttractor closestBody = null; Vector3 largestAcc = Vector3.zero; foreach (FauxGravityAttractor attractor in Universe.Instance.FauxGravityAttractors) { Vector3 acc = calcAcceleration(attractor); rigidbody.AddForce(acc * rigidbody.mass); if (acc.sqrMagnitude > largestAcc.sqrMagnitude) { closestBody = attractor; largestAcc = acc; } } if (closestBody != null && doesAlignWithGravity && largestAcc.sqrMagnitude > alignMinAcceleration * alignMinAcceleration) { //transform.up = -largestAcc.normalized; Quaternion newRot = Quaternion.FromToRotation(transform.up, -largestAcc.normalized) * transform.rotation; transform.rotation = Quaternion.RotateTowards(transform.rotation, newRot, ROTATION_SPEED * Time.deltaTime); } }
private void OnEnable() { GameObject bigBall = GameObject.FindWithTag("BigBall"); attractor = bigBall.GetComponent <FauxGravityAttractor>(); }
void Start() { rb = GetComponent <Rigidbody>(); attractor = FauxGravityAttractor.instance; }
void Awake() { instance = this; col = GetComponent <SphereCollider>(); }
private Vector3 calcAcceleration(FauxGravityAttractor attractor) { Vector3 heading = attractor.transform.position - transform.position; return(heading.normalized * (float)(Universe.BIG_G * (attractor.mass / heading.sqrMagnitude))); }
public void spawnTrees(int numTrees1, int numTrees2, int numTrees3, int numTrees4, int numShrub, int numTrees5, int numTrees6, int numTrees7, int numTrees8, int numTrees9, int numTrees10, int numTrees11, int numTrees12) { //Previously known as Start num_Trees = numTrees1 + numTrees2 + numTrees3 + numTrees4 + numShrub + numTrees5 + numTrees6 + numTrees7 + numTrees8 + numTrees9 + numTrees10 + numTrees11 + numTrees12; planet = GameObject.Find("Planet").GetComponent<FauxGravityAttractor>(); //GameObject tree; /*if (Application.loadedLevelName == "Tutorial") { num_Trees = 6; } */ //Spawn Trees for (int i=0; i < numTrees1; ++i) { //int index = Random.Range (0, 4); // tree = chooseTree (0); addTree (tree1); } for (int i=0; i < numTrees2; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (1); addTree (tree2); } for (int i=0; i < numTrees3; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree3); } for (int i=0; i < numTrees4; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree4); } for (int i=0; i < numShrub; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (); addTree (shrub); } for (int i=0; i < numTrees5; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree5); } for (int i=0; i < numTrees6; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree6); } for (int i=0; i < numTrees7; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree7); } for (int i=0; i < numTrees8; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree8); } for (int i=0; i < numTrees9; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree9); } for (int i=0; i < numTrees10; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree10); } for (int i=0; i < numTrees11; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree11); } for (int i=0; i < numTrees12; ++i) { //int index = Random.Range (0, 4); //tree = chooseTree (2); addTree (tree12); } }
public void setAttractor(GameObject a) { attractor = a.GetComponent <FauxGravityAttractor>(); }