void Start() { rb = GetComponent <Rigidbody>(); jump = new Vector3(0.0f, 100.0f, 0.0f); //Added to test InvertedGravity player_grv_individualGravity = this.GetComponent <GRV_IndividualGravity>(); //Finish Add }
// ------------------------------------------------------------------------------ // FUNCTIONS // ------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------ * Function Name: * Return types: N/A * Argument types: N/A * Author: * Date Created: * Last Updated: * ------------------------------------------------------------------------------ * Purpose: * ------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------ * Function Name: Start * Return types: N/A * Argument types: N/A * Author: * Date Created: * Last Updated: * ------------------------------------------------------------------------------ * Purpose: * ------------------------------------------------------------------------------ */ private void Start() { destroyTime = timeTillFall * 10; rb = this.GetComponent <Rigidbody>(); grv_IndividualGravity = this.GetComponent <GRV_IndividualGravity>(); rb.isKinematic = true; grv_IndividualGravity.enabled = false; }
//End Update private void OnCollisionStay(Collision collision) { //Only run if the object has an individualGravity script attached if (collision.gameObject.GetComponent <GRV_IndividualGravity>() != null) { GRV_IndividualGravity grv_IndividualGravity = collision.gameObject.GetComponent <GRV_IndividualGravity>(); //Runs a for loop to find the element in the gravityFigures list for (int i = 0; i < gravityFigures.Count; i++) { //Once it finds the gravity figure associated with the segmentGravity of the individualGravity script if (gravityFigures[i] == grv_IndividualGravity.SegmentGravity) { if (i - differnceInGravityNeeded > 0) { upwardBreaking = gravityFigures[i - differnceInGravityNeeded]; } else //Set to 0 if there isn't a gravity that is within the above range { upwardBreaking = 0; } if (i + differnceInGravityNeeded <= gravityFigures.Count - 1) { downwardBreaking = gravityFigures[i + differnceInGravityNeeded]; } else //Set just outside of gGun settings if a gravity isn't within the range above. { downwardBreaking = gravityFigures[gravityFigures.Count - 1] + 1; } //Debug.Log("Found a match and it is: " + gravityFigures[i] + " | downwardBreaking is: " + downwardBreaking + " | upwardBreaking is: " + upwardBreaking); } } //Destroying the platform from ABOVE if (topCollision && grv_IndividualGravity.GunGravity >= downwardBreaking && grv_IndividualGravity.GunGravity != 0) { Destroy(gameObject.transform.parent.gameObject); } //Destroying the platform from BELOW else if (!topCollision && grv_IndividualGravity.GunGravity <= upwardBreaking && grv_IndividualGravity.GunGravity != 0) { Destroy(gameObject.transform.parent.gameObject); } } }
void Awake() { rb = GetComponent <Rigidbody>(); //lL = FindObjectOfType<WLD_LevelLoader>(); //Ref to levelLoader script - will need to update to ref specific Teleporter's Segement selection later //Added to test InvertedGravity player_grv_individualGravity = this.GetComponent <GRV_IndividualGravity>(); //Finish Add //plr_Jump = GetComponent<PLR_Jump>(); plr_Shoot = FindObjectOfType <PLR_Shoot>(); healthScript = this.GetComponent <WLD_HealthDmg>(); rb.isKinematic = false; rb.useGravity = false; isFrozen = false; hashIDs = FindObjectOfType <UNA_HashIDs>(); anim = playerGFX.GetComponentInChildren <Animator>(); }