private static bool CheckEffectorForce(GameObject i_Go) { if (i_Go == null) { return(true); } Effector2D effector2D = i_Go.GetComponent <Effector2D>(); if (effector2D == null) { LogWarning(i_Go.name + " hasn't a valid effector."); return(true); } bool errorOccurred = false; if (effector2D is AreaEffector2D) { AreaEffector2D areaEffector2D = (AreaEffector2D)effector2D; errorOccurred = (Mathf.Abs(areaEffector2D.forceMagnitude) < 0.1f); } if (errorOccurred) { LogWarning(i_Go.name + " has an invalid force magnitude."); } return(errorOccurred); }
private static bool CheckEffectorAngle(GameObject i_Go, float i_Angle) { if (i_Go == null) { return(true); } Effector2D effector2D = i_Go.GetComponent <Effector2D>(); if (effector2D == null) { LogWarning(i_Go.name + " hasn't a valid effector."); return(true); } bool errorOccurred = false; if (effector2D is AreaEffector2D) { AreaEffector2D areaEffector2D = (AreaEffector2D)effector2D; errorOccurred = !Mathf.Approximately(areaEffector2D.forceAngle, i_Angle); } if (errorOccurred) { LogWarning(i_Go.name + " has an invalid force angle."); } return(errorOccurred); }
private void getEffectors() { aeHorizontal = GetComponent <AreaEffector2D> (); foreach (Transform child in transform) { if (child.name == "Vertical") { aeVertical = child.GetComponent <AreaEffector2D> (); } if (child.name == "BasilarSpring") { aeBasilarSpring = child.GetComponent <AreaEffector2D> (); } if (child.name == "BarrierLeft") { aeLeftBarrier = child.GetComponent <AreaEffector2D> (); } if (child.name == "BarrierRight") { aeRightBarrier = child.GetComponent <AreaEffector2D> (); } } }
void Start() { area = GetComponent <AreaEffector2D>(); //target = FindObjectOfType<PlayerController>().gameObject.transform; //initialD = Vector2.Distance(transform.position, target.position); //rigidbody2D.isKinematic = true; }
private void Start() { if (leftArm != null) { lArmEffector = leftArm.GetComponent <AreaEffector2D>(); } }
void Start() { AreaEffector2D areaEffector2D = GetComponent <AreaEffector2D>(); areaEffector2D.drag = data.drag; areaEffector2D.angularDrag = data.angularDrag; }
private void Start() { //Find the areaEffectors in children foreach (Transform child in transform) { switch (child.name) { case "Strong": strongWind = child.GetComponent <AreaEffector2D>(); break; case "Middle": middleWind = child.GetComponent <AreaEffector2D>(); break; case "Weak": weakWind = child.GetComponent <AreaEffector2D>(); break; } } //Set original values strongForce = strongWind.forceMagnitude; middleForce = middleWind.forceMagnitude; weakForce = weakWind.forceMagnitude; }
private void Update() { if (GameManager.instance.sceneName == "Level4") { windArea = GameObject.Find("WindArea").GetComponent <AreaEffector2D>(); } }
private void PullObjectsForEveryone(string playerName) { if (playerName == "green(Clone)") { block = GameObject.FindGameObjectWithTag("block"); a = GameObject.FindWithTag("VisionPlayer").GetComponent <AreaEffector2D>(); boxes = GameObject.FindWithTag("VisionPlayer").GetComponents <BoxCollider2D>(); if (block != null && a != null && boxes != null && !logCalled) { Debug.Log("Is In Game!!!!! Nothing to worry about"); logCalled = true; } } else if (playerName == "blek(Clone)") { boxes = GameObject.FindWithTag("StrengthPlayer").GetComponents <BoxCollider2D>(); } else if (playerName == "red(Clone)") { boxes = GameObject.FindWithTag("FirePlayer").GetComponents <BoxCollider2D>(); } else if (playerName == "blue(Clone)") { boxes = GameObject.FindWithTag("IcePlayer").GetComponents <BoxCollider2D>(); } else { Debug.Log("something is wrong, can't find prefab"); } }
void Start() { obj = wind_prefab.GetComponent <AreaEffector2D>(); Last_wind_time = Time.time; Time_interval = 7f; right = false; }
// void Start() { slab = GetComponent<BoxCollider2D>(); playercontrol = FindObjectOfType<PlayerControls>(); playermovement = FindObjectOfType<PlayerMovements>(); weightcontrol = FindObjectOfType<weightController>(); leveLength = GetComponent<BoxCollider2D>(); areaeffector = GetComponent<AreaEffector2D>(); afterflightCC = FindObjectOfType<AfterFlightCollisionController>(); load = GameObject.Find("Load_2"); load.GetComponent<Renderer>().enabled = false; areaeffector.enabled = false; player = GameObject.Find("Player"); seeSawHinge = GetComponent<HingeJoint2D>(); seeSawHinge.enabled = false; this.gameObject.GetComponent<Rigidbody2D>().isKinematic = true; // slabWidth = GetComponent<BoxCollider2D>().size.x; //Debug.Log("slabWidth" + slabWidth ); fulcrumObj = GameObject.FindWithTag("Fulcrum"); fulcrum_Start_x = fulcrumObj.transform.position.x; //Debug.Log("fulcrum at start: " + fulcrum_Start_x); anchor_y = seeSawHinge.anchor.y; // }
void Start() { //Debug.Log("Start called"); slab = GetComponent<BoxCollider2D>(); playercontrol = FindObjectOfType<PlayerControls>(); playermovement = FindObjectOfType<PlayerMovements>(); weightcontrol = FindObjectOfType<weightController>(); leveLength = GetComponent<BoxCollider2D>(); areaeffector = GetComponent<AreaEffector2D>(); afterflightCC = FindObjectOfType<AfterFlightCollisionController>(); //load = GameObject.Find("Loads/Load_2"); load = this.transform.parent.GetChild(2).GetChild(0).gameObject; load.GetComponent<Renderer>().enabled = false; areaeffector.enabled = false; player = GameObject.Find("Player"); seeSawHinge = GetComponent<HingeJoint2D>(); seeSawHinge.enabled = false; this.gameObject.GetComponent<Rigidbody2D>().isKinematic = true; // slabWidth = GetComponent<BoxCollider2D>().size.x; //Debug.Log("slabWidth" + slabWidth ); fulcrumObj = GameObject.FindWithTag("Fulcrum"); fulcrum_Start_x = fulcrumObj.transform.position.x; //Debug.Log("fulcrum at start: " + fulcrum_Start_x); anchor_y = seeSawHinge.anchor.y; messagecontrol = FindObjectOfType<MessageController>(); //Reset the static variable as flight control is dependent on this variable and if not reset gives issues with sound AfterFlightCollisionController.hasPlayerLanded = false; activateFly = false; }
// Use this for initialization void Start() { GameObject wind = new GameObject("wind"); wind.transform.parent = this.transform; wind.transform.localPosition = Vector3.zero; wind.transform.rotation = this.transform.rotation; wind.AddComponent <BoxCollider2D>(); BoxCollider2D windBox = wind.GetComponent <BoxCollider2D>(); windBox.size = new Vector2(this.GetComponent <BoxCollider2D>().size.x, effectArea); windBox.usedByEffector = true; windBox.isTrigger = true; windBox.offset = new Vector2(0, windBox.size.y / 2); wind.AddComponent <AreaEffector2D>(); AreaEffector2D windEffect = wind.GetComponent <AreaEffector2D>(); windEffect.forceAngle = 90; GameObject windAnimation = this.transform.Find("windGfcs").gameObject; windAnimation.transform.localScale = new Vector3(1, effectArea, 1); windAnimation.transform.localPosition = new Vector2(0, effectArea / 2); windEffect.forceMagnitude = windStrength; }
void Awake() { /* PlayerPrefs.DeleteAll(); */ string playerName = PlayerPrefs.GetString("playerName"); if (playerName != "ninja" && playerName != "girl") { playerName = "ninja"; } GameObject player = Instantiate(Resources.Load(playerName) as GameObject); player.transform.position = GameObject.FindGameObjectWithTag("playerPos").transform.position; fanChild = GameObject.FindGameObjectWithTag("fan"); fanAnimator = fanChild.GetComponent <Animator>(); fanChild.GetComponent <SpriteRenderer>().enabled = false; ninja = GameObject.FindGameObjectWithTag("ninja"); targetTransform = ninja.GetComponent <Transform>(); ninjaSr = ninja.GetComponent <SpriteRenderer>(); AreaEffector = GetComponent <AreaEffector2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); }
// Start is called before the first frame update void Start() { position = GetComponent <Transform>(); force = GetComponent <AreaEffector2D>(); force.forceMagnitude = ForceMagnitude; force.forceAngle = position.rotation.eulerAngles.z; }
void Start() { spikesRigidbody = GetComponent <Rigidbody2D>(); spikesAreaEffector = GetComponent <AreaEffector2D>(); initialPosition = transform.localPosition.y; StartCoroutine(SpikesMovementUp()); }
void OnTriggerStay2D(Collider2D other) { if (other.GetComponent <AreaEffector2D>() == true) { isInForceCurrent = true; forceCurrent = other.GetComponent <AreaEffector2D>(); } }
void Awake() { areaEffector = effectorBeam.GetComponent <AreaEffector2D>(); beamSpriteRenderer = effectorBeam.GetComponent <SpriteRenderer>(); beamStrength = areaEffector.forceMagnitude; effectorBeam.SetActive(false); }
// Start is called before the first frame update public void Start() { Vector3 vecInit = new Vector3(0, 0, 0); tornado = Instantiate(tornadoInit, vecInit, Quaternion.identity); d = this.gameObject.GetComponent <AreaEffector2D>(); setWind(); }
protected void init() { startPos = transform.position; calculateDirection(); effector = GetComponentInChildren <AreaEffector2D>(); startForce(); clock = new Clock(waitingTime); initialConfig = saveInitialTransformation(); }
void Start() { Maincam = GameObject.Find("Main Camera"); cameraBG = GameObject.Find("GOBGcameraBG"); RedCircle = GameObject.Find("GOBGcameraRedCircle"); Player = GameObject.Find("kucha"); AreaEffector = GameObject.Find("AreaEffectorsss"); AE2D = AreaEffector.GetComponent <AreaEffector2D>(); }
private void Awake() { //get required references shuttle = shuttle == null?GetComponentInParent <Shuttle>() : shuttle; thrusterArea = thrusterArea == null?GetComponentInChildren <AreaEffector2D>() : thrusterArea; thrusterCol = thrusterCol == null?thrusterArea.GetComponent <Component>() : thrusterCol; }
void OnTriggerExit2D(Collider2D other) { AreaEffector2D areaEffector = other.gameObject.GetComponent <AreaEffector2D>(); if (areaEffector != null) { active = false; } }
void OnTriggerExit2D(Collider2D other) { if (other.gameObject.GetComponent <AreaEffector2D>() != null) { effector = null; hitByWind = false; wind = null; } }
void OnTriggerStay2D(Collider2D other) { if (other.gameObject.GetComponent <AreaEffector2D>() != null) { wind = other.gameObject; effector = wind.GetComponent <AreaEffector2D>(); hitByWind = true; } }
// Start is called before the first frame update void Start() { type = this.tag; areaEffector = gameObject.GetComponent <AreaEffector2D>(); /* * angle = Mathf.Atan2(p2.position.y - p1.position.y, p2.position.x - p1.position.x) * 180 / Mathf.PI; * areaEffector.forceAngle = angle - 25; */ }
// Use this for initialization void Start() { animator = GetComponent <Animator>(); startWaitingTime = Time.fixedTime; startBlowingTime = Time.fixedTime; prtcle = smoke.GetComponent <ParticleSystem>(); aoe = effectArea.GetComponent <AreaEffector2D>(); audioSource = GetComponent <AudioSource>(); StopBlowing(); }
private void Start() { try { green = GameObject.FindWithTag("VisionPlayer"); greenBoxes = green.GetComponents <BoxCollider2D>(); a = green.GetComponent <AreaEffector2D>(); } catch { Debug.Log("If the message (Is In Game!) appears, then ignore this: Trying to find the magnet player but it isn't in the game: lines: 14-16 in Boxes.cs, this is the error but if you just load the magnet player then it will be fixed."); } }
void Start() { SpriteWind = GetComponent <SpriteRenderer>(); Efector = GetComponent <AreaEffector2D>(); AlphaWind.r = 255; AlphaWind.g = 255; AlphaWind.b = 255; AlphaWind.a = 0; TimeOfLife = Random.Range(MinTimeOfLife, MaxTimeOfLife + 1); Efector.forceMagnitude = Random.Range(-MaxTimeOfLife, -MinTimeOfLife); }
void OnTriggerExit2D(Collider2D other) { if (savedGO) { if (other.gameObject == referenceWind) { referenceWind = null; effector = null; } } }