void Start() { rigidbody = GetComponent <Rigidbody2D> (); animator = GetComponent <Animator> (); currentSpeed = moveSpeed; startingConstraints = rigidbody.constraints; }
public void Constraint(RigidbodyConstraints2D constraints) { cachedVelocity = Velocity; cachedAngularVelocity = AngularVelocity; entityRigidbody.constraints = constraints; }
void Start() { bottomAngle = gameObject.transform.Find("top/bottomAngle"); middleAngle = gameObject.transform.Find("top/middleAngle"); topAngle = gameObject.transform.Find("top/topAngle"); topAngleHolder = gameObject.transform.Find("top/topAngleHolder"); topBody = gameObject.transform.Find("top"); tailBody = gameObject.transform.Find("top/bottom"); eyelid = gameObject.transform.Find("top/eyes/eyelid"); topBodyCons = topBody.GetComponent <Rigidbody2D>().constraints; for (int i = 0; i <= 4; i++) { allMouth[i] = new Sprite[5]; for (int i2 = 0; i2 <= 4; i2++) { allMouth[i][i2] = Resources.Load("mouth\\lose" + i + "Up" + i2 + "Down", typeof(Sprite)) as Sprite; } } eyelidStartingPosition = eyelid.localPosition.y; controlEyelid(); controlMouth(); }
public void FreezeItem(bool freeze) { // freeze/unfreeze the bonus item on screen // NOTE: this will be called from the GameManager but could be used in other scripts if (freeze) { freezeItem = true; animateItem = animate; if (animateItem) { Animate(false); } rb2dConstraints = rb2d.constraints; freezeVelocity = rb2d.velocity; rb2d.constraints = RigidbodyConstraints2D.FreezeAll; } else { freezeItem = false; if (animateItem) { Animate(true); } rb2d.constraints = rb2dConstraints; rb2d.velocity = freezeVelocity; } }
/// <summary> /// Sets the state of constraints for the source Rigidbody2D. /// </summary> public static Rigidbody2D ToggleConstraints(this Rigidbody2D source, RigidbodyConstraints2D constraints, bool state) { source.constraints = source.constraints.BitwiseToggle(constraints, state); return(source); }
void Start() { Time.timeScale = 1; blackBackground.gameObject.SetActive(false); constraints = RigidbodyConstraints2D.FreezeRotation; spriterenderer = GetComponent <SpriteRenderer>(); doorSprite = GameObject.FindGameObjectWithTag("door").GetComponent <SpriteRenderer>().sprite; if (SceneManager.GetActiveScene().buildIndex > PlayerPrefs.GetInt("WhichLevel")) { PlayerPrefs.SetInt("WhichLevel", SceneManager.GetActiveScene().buildIndex); } else if (PlayerPrefs.GetInt("WhichLevel") == null) { PlayerPrefs.SetInt("Kaçıncılevel", SceneManager.GetActiveScene().buildIndex); } physic = GetComponent <Rigidbody2D>(); if (SceneManager.GetActiveScene().buildIndex > PlayerPrefs.GetInt("WhichLevel")) { PlayerPrefs.SetInt("WhichLevel", SceneManager.GetActiveScene().buildIndex); } camera = GameObject.FindGameObjectWithTag("MainCamera"); cameraFirstPos = camera.transform.position - transform.position; healthText.text = "HEALTH " + health; goldText.text = goldCounter + "/" + howmuchGold; }
// Use this for initialization void Start() { this.attackSpan = 1.7f; this.attackDelta = 0; this.player = GameObject.Find("cat"); this.R = Random.Range(0.0f, 1.0f); this.G = Random.Range(0.0f, 1.0f); this.B = Random.Range(0.0f, 1.0f); this.boxcol = GetComponent <BoxCollider2D>(); this.rigidbody2D = GetComponent <Rigidbody2D>(); this.animator = GetComponent <Animator>(); this.die = false; this.dieDelta = 0; this.dieSpan = 0.5f; this.start = true; this.GameDirector = GameObject.Find("GameDirector"); this.originalConstraints = this.rigidbody2D.constraints; this.damaged = false; this.damagedDelta = 0; this.damagedSpan = 0.5f; this.SlimeColor = new Color(0, 1, 0); this.bound = 0.01f; this.boundSpan = 0.3f; this.boundDelta = 0; this.direction = -1; this.walkSpan = 1.2f; this.walkDelta = 0; }
public void FreezeBullet(bool freeze) { // freeze/unfreeze the bullets on screen // zero animation speed and freeze XYZ rigidbody constraints // NOTE: this will be called from the GameManager but could be used in other scripts if (freeze) { freezeBullet = true; wasFrozen = true; rb2dConstraints = rb2d.constraints; animatorSpeed = animator.speed; animator.speed = 0; rb2d.constraints = RigidbodyConstraints2D.FreezeAll; rb2d.velocity = Vector2.zero; } else { // only unfreeze if was frozen otherwise expect weird results if (wasFrozen) { freezeBullet = false; animator.speed = animatorSpeed; rb2d.constraints = rb2dConstraints; rb2d.velocity = bulletDirection * bulletSpeed; } } }
public void MouseDrag() { mousePressed = !mousePressed; if (mousePressed) { DeactivateOther(); if (this.name == "RopeSegmentKnot") { RigidbodyConstraints2D constraints = RigidbodyConstraints2D.FreezeAll; GetComponent <Rigidbody2D>().constraints = constraints; } } else { for (int i = 0; i < trapObjs.Length; i++) { trapObjs[i].enabled = true; } if (this.name == "RopeSegmentKnot") { RigidbodyConstraints2D constraints = RigidbodyConstraints2D.FreezeRotation; GetComponent <Rigidbody2D>().constraints = constraints; } } }
private void Start() { collider = GetComponent <BoxCollider2D>(); gizmoHelper = GameObject.Find("[GizmoHelper]").GetComponent <GizmoHelper>(); if (transform.localEulerAngles.z == 0 || transform.localEulerAngles.z == 180) { constraints = RigidbodyConstraints2D.FreezePositionX; } else { constraints = RigidbodyConstraints2D.FreezePositionY; } switch (Mathf.Round(transform.localEulerAngles.z).ToString()) { case ("0"): direction = new Vector2(0, 1); break; case ("90"): direction = new Vector2(-1, 0); break; case ("180"): direction = new Vector2(0, -1); break; case ("270"): direction = new Vector2(1, 0); break; } }
// Inspired by https://gamedev.stackexchange.com/questions/142791/how-can-i-fade-a-game-object-in-and-out-over-a-specified-duration // Used by objects with Rigidbody2D's that you don't want to move while fading public static IEnumerator Fade(Rigidbody2D constr, SpriteRenderer sprite, float start, float target, float duration) { float time = 0; Color col = sprite.color; //float start = col.a; RigidbodyConstraints2D original = constr.constraints; constr.constraints |= RigidbodyConstraints2D.FreezePositionX; //constr.constraints |= RigidbodyConstraints2D.FreezePositionY; while (time < duration) { time += Time.deltaTime; float blend = Mathf.Clamp01(time / duration); col.a = Mathf.Lerp(start, target, blend); sprite.color = col; yield return(null); } constr.constraints = original; }
public void FreezeEnemy(bool freeze) { // freeze/unfreeze the enemy on screen // zero animation speed and freeze XYZ rigidbody constraints // NOTE: this will be called from the GameManager but could be used in other scripts if (freeze) { freezeEnemy = true; wasFrozen = true; animatorSpeed = animator.speed; rb2dConstraints = rb2d.constraints; freezeVelocity = rb2d.velocity; animator.speed = 0; rb2d.constraints = RigidbodyConstraints2D.FreezeAll; } else { // only unfreeze if was frozen otherwise expect weird results if (wasFrozen) { freezeEnemy = false; wasFrozen = false; animator.speed = animatorSpeed; rb2d.constraints = rb2dConstraints; rb2d.velocity = freezeVelocity; } } }
public override void OnInspectorGUI() { Rigidbody2D target = this.target as Rigidbody2D; base.serializedObject.Update(); this.m_ShowMass.target = !target.useAutoMass; EditorGUILayout.PropertyField(this.m_UseAutoMass, new GUILayoutOption[0]); bool enabled = GUI.enabled; GUI.enabled = !target.useAutoMass; EditorGUILayout.PropertyField(this.m_Mass, new GUILayoutOption[0]); GUI.enabled = enabled; base.serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); this.m_Constraints.isExpanded = EditorGUILayout.Foldout(this.m_Constraints.isExpanded, "Constraints"); GUILayout.EndHorizontal(); RigidbodyConstraints2D intValue = (RigidbodyConstraints2D)this.m_Constraints.intValue; if (this.m_Constraints.isExpanded) { EditorGUI.indentLevel++; this.ToggleFreezePosition(intValue, m_FreezePositionLabel, 0, 1); this.ToggleFreezeRotation(intValue, m_FreezeRotationLabel, 2); EditorGUI.indentLevel--; } if (intValue == RigidbodyConstraints2D.FreezeAll) { EditorGUILayout.HelpBox("Rather than turning on all constraints, you may want to consider removing the Rigidbody2D component which makes any colliders static. This gives far better performance overall.", MessageType.Info); } }
protected virtual void Start() { rigidbody = GetComponent <Rigidbody2D>(); originalLinearDrag = rigidbody.drag; originalAngularDrag = rigidbody.angularDrag; originalConstraints = rigidbody.constraints; }
void Update() { if (Input.GetMouseButtonDown(0)) { //See if we hit any draggables Ray ray = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity, draggableLayers); if (hit.rigidbody != null) { //save some drag info currentlyDraggedTransform = hit.transform; currentlyDraggedRigidbody = hit.transform.GetComponent <Rigidbody2D>(); oldConstraints = currentlyDraggedRigidbody.constraints; if (freezeRotation) { currentlyDraggedRigidbody.constraints = currentlyDraggedRigidbody.constraints | RigidbodyConstraints2D.FreezeRotation; } //Get the current offset localPickOffset = hit.transform.InverseTransformPoint(GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition)); //Instantiate the hinge joint GameObject jointTrans = Instantiate(dragPrefab, GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition), currentlyDraggedTransform.rotation) as GameObject; currentlyDraggedJoint = jointTrans.GetComponent <HingeJoint2D>(); //Populate the hinge joint currentlyDraggedJoint.anchor = Vector2.zero; currentlyDraggedJoint.connectedAnchor = localPickOffset; currentlyDraggedJoint.connectedBody = currentlyDraggedRigidbody; //Let the object know that we've started dragging it currentlyDraggedTransform.gameObject.SendMessage("OnStartDrag", SendMessageOptions.DontRequireReceiver); } } //Stop dragging if (Input.GetMouseButtonUp(0)) { if (currentlyDraggedTransform != null) { //Let the object know that we have stopped dragging it currentlyDraggedTransform.gameObject.SendMessage("OnStopDrag", SendMessageOptions.DontRequireReceiver); currentlyDraggedTransform = null; } if (currentlyDraggedRigidbody != null) { currentlyDraggedRigidbody.constraints = oldConstraints; currentlyDraggedRigidbody = null; } if (currentlyDraggedJoint != null) { Destroy(currentlyDraggedJoint.gameObject); } } }
void Start() { coll = GetComponent <Collision>(); rb = GetComponent <Rigidbody2D>(); playerConstraints = rb.constraints; anim = GetComponentInChildren <AnimationScript>(); stepSource = GetComponent <AudioSource>(); }
void Start() { body = GetComponent <Rigidbody2D>(); constraints = body.constraints; animator = GetComponent <FigureAnimationManager>(); startPosition = transform.position; SetHeadText(); }
private void Start() { _rigidBody2D = GetComponent<Rigidbody2D>(); _collider2D = GetComponent<Collider2D>(); _playerCollider = Player.instance.collider2D; _defaultConstraints = _rigidBody2D.constraints; _noPushConstraints = _defaultConstraints | RigidbodyConstraints2D.FreezePositionX; }
// Start is called before the first frame update void Start() { wallJumpInfluence = false; plat = null; playerRB = GetComponent <Rigidbody2D>(); surfacesTouching = 0; touching = new Dictionary <Collider2D, int>(); dashes = maxDashes; dirFacing = 1; trueGrav = playerRB.gravityScale; anim = GetComponent <Animator>(); level = transform.parent; baseVelocity = 0; respawnPos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z); walljumpAttack = false; //Initialize min and max values for the timeBar, and set initial value timeBar.maxValue = 100; timeBar.minValue = 0; timeHealthValue = 100; timeBar.value = timeHealthValue; //Set speed in air airSpeed = 200; dashSpeed = 150; //Set Time bool timePowerOn = false; timeTurningOn = false; //Initialize WaitForSeconds variables secondsToWaitForDash = 0.15f; secondsToWaitForWallJump = 0.4f; secondsToWaitForJump = 0.03f; //Initialize dialogue booleans inDialogue = false; canEnterDialogue = false; showNextSentence = false; continueDialogue = false; takingDamage = false; takingDamageStun = false; spriteRenderer = GetComponent <SpriteRenderer>(); originalColor = spriteRenderer.material.color; playerLayer = LayerMask.NameToLayer("Player"); enemyLayer = LayerMask.NameToLayer("Enemy"); //Save original constraints originalConstraints = playerRB.constraints; //Buffer Seconds bufferSeconds = 0.5f; }
void Awake() { col = transform.Find("WallCollider").gameObject; rb = GetComponent <Rigidbody2D>(); line = GetComponent <LineRenderer>(); audioSource = GetComponent <AudioSource>(); originalConstraints = rb.constraints; }
private void Awake() { m_Character = GetComponent <PlatformerCharacter2D>(); spriteEffector = GetComponent <SpriteEffector>(); rbody = GetComponent <Rigidbody2D>(); originalConstraints = rbody.constraints; damageManager = GetComponent <PlayerDamageManager>(); enemyHolder = this.transform.Find("EnemyHolder"); }
public override void OnInspectorGUI() { Rigidbody2D rigidbody2D = base.target as Rigidbody2D; base.serializedObject.Update(); EditorGUILayout.PropertyField(this.m_BodyType, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Material, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Simulated, new GUILayoutOption[0]); if (this.m_BodyType.hasMultipleDifferentValues) { EditorGUILayout.HelpBox("Cannot edit properties that are body type specific when the selection contains different body types.", MessageType.Info); } else { this.m_ShowIsStatic.target = (rigidbody2D.bodyType != RigidbodyType2D.Static); if (EditorGUILayout.BeginFadeGroup(this.m_ShowIsStatic.faded)) { this.m_ShowIsKinematic.target = (rigidbody2D.bodyType != RigidbodyType2D.Kinematic); if (EditorGUILayout.BeginFadeGroup(this.m_ShowIsKinematic.faded)) { EditorGUILayout.PropertyField(this.m_UseAutoMass, new GUILayoutOption[0]); EditorGUI.BeginDisabledGroup(rigidbody2D.useAutoMass); EditorGUILayout.PropertyField(this.m_Mass, new GUILayoutOption[0]); EditorGUI.EndDisabledGroup(); EditorGUILayout.PropertyField(this.m_LinearDrag, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AngularDrag, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_GravityScale, new GUILayoutOption[0]); } Rigidbody2DEditor.FixedEndFadeGroup(this.m_ShowIsKinematic.faded); if (!this.m_ShowIsKinematic.target) { EditorGUILayout.PropertyField(this.m_UseFullKinematicContacts, new GUILayoutOption[0]); } EditorGUILayout.PropertyField(this.m_CollisionDetection, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_SleepingMode, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Interpolate, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); this.m_Constraints.isExpanded = EditorGUILayout.Foldout(this.m_Constraints.isExpanded, "Constraints", true); GUILayout.EndHorizontal(); RigidbodyConstraints2D intValue = (RigidbodyConstraints2D)this.m_Constraints.intValue; if (this.m_Constraints.isExpanded) { EditorGUI.indentLevel++; this.ToggleFreezePosition(intValue, Rigidbody2DEditor.m_FreezePositionLabel, 0, 1); this.ToggleFreezeRotation(intValue, Rigidbody2DEditor.m_FreezeRotationLabel, 2); EditorGUI.indentLevel--; } if (intValue == RigidbodyConstraints2D.FreezeAll) { EditorGUILayout.HelpBox("Rather than turning on all constraints, you may want to consider removing the Rigidbody2D component which makes any colliders static. This gives far better performance overall.", MessageType.Info); } } Rigidbody2DEditor.FixedEndFadeGroup(this.m_ShowIsStatic.faded); } base.serializedObject.ApplyModifiedProperties(); this.ShowBodyInfoProperties(); }
IEnumerator CancelEnemyFreeze(Rigidbody2D Enemy, RigidbodyConstraints2D originalConstraints) { yield return(new WaitForSeconds(invincible_time)); if (Enemy != null) { Enemy.constraints = originalConstraints; } }
// constructor public MController(Rigidbody2D rigidbody, bool isFreezable = false) { _rigidbody = rigidbody; _lastConstraint = _rigidbody.constraints; if (isFreezable) { Freezer.trigger += Freeze; } }
// Use this for initialization void Start() { rbody = this.GetComponent <Rigidbody2D>(); constraints = rbody.constraints; if (isFlying == true) { this.transform.position = new Vector2(this.transform.position.x, this.transform.position.y + 1); } }
private void OnCollisionEnter2D(Collision2D collision) { GameObject player = collision.gameObject; if (player.tag == "Player") { freezeRb = RigidbodyConstraints2D.FreezeRotation; //Si el player esta empujando hacia la derecha if (player.GetComponent <PlayerController>().UltimaDireccion().x != 0) { if (bloqueos.bloquearDerecha) { if (collision.gameObject.transform.position.x < transform.position.x) { freezeRb = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation; } //else //freezeRb = RigidbodyConstraints2D.FreezeRotation; } //Si el player empujando hacia la izquierda if (bloqueos.bloquearIzquierda) { if (collision.gameObject.transform.position.x > transform.position.x) { freezeRb = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation; } //else //freezeRb = RigidbodyConstraints2D.FreezeRotation; } } else { //Si el player esta empujando hacia arriba if (bloqueos.bloquearArriba) { if (collision.gameObject.transform.position.y > transform.position.y) { freezeRb = RigidbodyConstraints2D.FreezePositionY | RigidbodyConstraints2D.FreezeRotation; } //else //freezeRb = RigidbodyConstraints2D.FreezeRotation; } //Si el player esta empujando hacia abajo if (bloqueos.bloquearAbajo) { if (collision.gameObject.transform.position.y < transform.position.y) { freezeRb = RigidbodyConstraints2D.FreezePositionY | RigidbodyConstraints2D.FreezeRotation; } //else //freezeRb = RigidbodyConstraints2D.FreezeRotation; } } } }
void pickUpItem() { isCarrying = true; carriedItem = grabHand.interactableObject; carriedItem.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); previousConstraints = carriedItem.GetComponent <Rigidbody2D>().constraints; carriedItem.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation; carriedItem.transform.rotation = new Quaternion(0, 0, 0, 0); carriedItem.GetComponent <Rigidbody2D>().position = holdPoint.transform.position; }
//Constraints del Player protected virtual void UpdateConstraints() { RigidbodyConstraints2D constraints = RigidbodyConstraints2D.FreezeRotation; if (_xInput == 0) { constraints = RigidbodyConstraints2D.FreezeRotation | RigidbodyConstraints2D.FreezePositionX; } _rigidbody.constraints = constraints; }
void Start() { //When the game begins, set the animator controller, rigidbody, and sounds Rigidbody = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); soundSource.clip = jumpLand; jumpSource.clip = jump; throwSource.clip = bombThrow; originalConstraints = RigidbodyConstraints2D.FreezeRotation; }
void Start() { RigidbodyConstraints2D rc2D = GetComponent <Rigidbody2D>().constraints; DestroyImmediate(GetComponent <Rigidbody2D>()); playerRigidbody2D = gameObject.AddComponent <Rigidbody2D>(); playerRigidbody2D.constraints = rc2D; anim = GetComponent <Animator>(); blockDuration = attackDuration * 3f; }
public IEnumerator TempFreezeMovement(float delay) { currentConstraints = RigidbodyConstraints2D.FreezeAll; rb2d.constraints = currentConstraints; yield return(new WaitForSeconds(delay)); currentConstraints = RigidbodyConstraints2D.FreezeRotation; rb2d.constraints = currentConstraints; }
private void ToggleFreezeRotation(RigidbodyConstraints2D constraints, GUIContent label, int z) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); Rect position = GUILayoutUtility.GetRect(EditorGUIUtility.fieldWidth, EditorGUILayout.kLabelFloatMaxW, 16f, 16f, EditorStyles.numberField); int id = GUIUtility.GetControlID(0x1c3f, FocusType.Keyboard, position); position = EditorGUI.PrefixLabel(position, id, label); position.width = 30f; this.ConstraintToggle(position, "Z", constraints, z); GUILayout.EndHorizontal(); }
private void ToggleFreezePosition(RigidbodyConstraints2D constraints, GUIContent label, int x, int y) { GUILayout.BeginHorizontal(); Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.fieldWidth, EditorGUILayout.kLabelFloatMaxW, 16f, 16f, EditorStyles.numberField); int controlId = GUIUtility.GetControlID(7231, FocusType.Keyboard, rect); Rect r = EditorGUI.PrefixLabel(rect, controlId, label); r.width = 30f; this.ConstraintToggle(r, "X", constraints, x); r.x += 30f; this.ConstraintToggle(r, "Y", constraints, y); GUILayout.EndHorizontal(); }
public RigidData(Rigidbody2D originalData) { angularDrag = originalData.angularDrag; centerOfMass = originalData.centerOfMass; collisionDetectionMode = originalData.collisionDetectionMode; constraints = originalData.constraints; drag = originalData.drag; freezeRotation = originalData.freezeRotation; gravityScale = originalData.gravityScale; inertia = originalData.inertia; interpolation = originalData.interpolation; isKinematic = originalData.isKinematic; mass = originalData.mass; simulated = originalData.simulated; }
public Rigidbody2DSettings(Rigidbody2D rigidbody) { _rigidbody = rigidbody; _isKinematic = rigidbody.isKinematic; _velocity = rigidbody.velocity; _angularVelocity = rigidbody.angularVelocity; _mass = rigidbody.mass; _linearDrag = rigidbody.drag; _angularDrag = rigidbody.angularDrag; _gravityScale = rigidbody.gravityScale; _interpolate = rigidbody.interpolation; _collisionDetection = rigidbody.collisionDetectionMode; _sleepingMode = rigidbody.sleepMode; _constraints = rigidbody.constraints; }
private void ConstraintToggle(Rect r, string label, RigidbodyConstraints2D value, int bit) { bool flag1 = (value & (RigidbodyConstraints2D) (1 << bit)) != RigidbodyConstraints2D.None; EditorGUI.showMixedValue = (this.m_Constraints.hasMultipleDifferentValuesBitwise & 1 << bit) != 0; EditorGUI.BeginChangeCheck(); int indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; bool flag2 = EditorGUI.ToggleLeft(r, label, flag1); EditorGUI.indentLevel = indentLevel; if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(this.targets, "Edit Constraints2D"); this.m_Constraints.SetBitAtIndexForAllTargetsImmediate(bit, flag2); } EditorGUI.showMixedValue = false; }
public void Freeze() { // Save current movement, so that it can be restored savedVelocity = rigidBody.velocity; savedConstraints = rigidBody.constraints; // Stop right there, criminal scum! Vector2 newVelocity = rigidBody.velocity; newVelocity.x = 0; rigidBody.velocity = newVelocity; // We need to mask the old constraints with the frozen X axis (want to keep rotation turned off) rigidBody.constraints = rigidBody.constraints | RigidbodyConstraints2D.FreezePositionX; isFrozen = true; // Set animation state animator.SetBool(GameConstants.RunState, false); }
// Use this for initialization void Start () { m_body = GetComponent<Rigidbody2D> (); m_constraintsWhenNotBlowing = m_body.constraints; }
// Use this for initialization void Start() { _timeElapsed = Cooldown; _myState = GetComponent<PlayerState>(); _myInput = GetComponent<PlayerInput>(); _myBody = GetComponent<Rigidbody2D>(); _myAnimator = GetComponent<Animator>(); _myParticles = GetComponentInChildren<ParticleSystem>(); _dayConstraints = RigidbodyConstraints2D.FreezeAll; _nightConstraints = RigidbodyConstraints2D.FreezeRotation; GameController.Instance.OnDay += OnDay; GameController.Instance.OnNight += OnNight; }