public static bool IsPlatformEffector(this Collider2D coll, out PlatformEffector2D effector) { effector = coll.GetComponent <PlatformEffector2D>(); return(effector != null); }
//------------------------------------------------------------------------------------------ // Awake //------------------------------------------------------------------------------------------ private void Awake() { thisCollider = GetComponent <BoxCollider2D>(); platform = GetComponent <PlatformEffector2D>(); }
private void Awake() { edgeCollider2D = GetComponent <EdgeCollider2D>(); platformEffector2D = GetComponent <PlatformEffector2D>(); }
private void Start() { _effector = GetComponent <PlatformEffector2D>(); _originalRotOffset = _effector.rotationalOffset; }
// Use this for initialization void Start() { pe2d = GetComponent <PlatformEffector2D>(); }
void Start() { //this effector variable gets the information from the PlatformEffector2D component. This allows us to change things around in the PlatformEffector2D component. effector = GetComponent <PlatformEffector2D>(); }
// Start is called before the first frame update void Start() { time = waitTime; effector = GetComponent <PlatformEffector2D>(); }
/// <summary> /// Perform the specified actions for the character /// </summary> /// <param name="action">A combined set of flags for all the actions the character should perform</param> public void Perform(Action action) { // Quit early if dead if (this.IsDead) { return; } // Check if we are blocking this.isBlocking = IsAction(action, Action.Block) && this.IsBlockEnabled; // Check if we are crouching this.isCrouching = IsAction(action, Action.Crouch); // Check for the running modifier key this.isRunningNormal = !IsAction(action, Action.RunModified); // Reset the jump count if we are on the ground if (this.isGrounded) { this.jumpCount = 0; } // Check for jumping down since we need to remove the regular jump flag if we are if (IsAction(action, Action.JumpDown)) { Collider2D ground = this.CheckGround(); if (ground != null) { PlatformEffector2D fx = ground.GetComponent <PlatformEffector2D>(); if (fx != null && fx.useOneWay) { ground.enabled = false; action &= ~Action.Jump; StartCoroutine(this.EnableAfter(this.JumpDownTimeout, ground)); } } } // Now check the rest of the keys for actions if (IsAction(action, Action.Jump) && !this.isJumpPressed) { // Prevent them jumping on ladders if (!this.isOnLadder) { if (this.isGrounded || (this.AllowWallJump && this.isOnWall)) { this.isJumpPressed = true; this.jumpCount = 1; } else if (this.AllowDoubleJump && this.jumpCount <= 1) { this.isJumpPressed = true; this.jumpCount = 2; } } } else if (IsAction(action, Action.QuickAttack)) { this.TriggerAction("TriggerQuickAttack"); } else if (IsAction(action, Action.Attack)) { this.TriggerAction("TriggerAttack"); } else if (IsAction(action, Action.Cast)) { this.TriggerAction("TriggerCast"); } else if (IsAction(action, Action.ThrowOff)) { this.TriggerAction("TriggerThrowOff"); } else if (IsAction(action, Action.ThromMain)) { this.TriggerAction("TriggerThrowMain"); } else if (IsAction(action, Action.Consume)) { this.TriggerAction("TriggerConsume"); } else if (this.isBlocking && !this.animatorObject.GetBool("IsBlocking")) { this.TriggerAction("TriggerBlock"); } else if (IsAction(action, Action.Hurt)) { // Apply some damage to test the animation this.ApplyDamage(10); } // Reset the blocking animation if they let go of the block button if (!this.isBlocking) { this.animatorObject.SetBool("IsBlocking", this.isBlocking); } }
private void Awake() { platform = GetComponent <PlatformEffector2D>(); col = GetComponent <Collider2D>(); }
void Start() { effector2D = gameObject.GetComponent <PlatformEffector2D>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); }
private IEnumerator StopFallThrough(PlatformEffector2D effector) { yield return(new WaitForSeconds(0.35f)); effector.rotationalOffset = 0.0f; }
private void Start() { przejscie = GetComponent <PlatformEffector2D>(); }
protected void Start() { bc = GetComponent <BoxCollider2D>(); pf = GetComponent <PlatformEffector2D>(); }
public static bool TryGetPlatformEffector(Collider2D _collider, out PlatformEffector2D _platform_effector) { return(Instance.m_platform_effector_cache.TryGetValue(_collider, out _platform_effector)); }
/*public static bool ColliderHasAudioSurface (Collider2D collider) * { * return Instance.m_AudioSurfaceCache.ContainsKey (collider); * }*/ /*public static bool TryGetMovingPlatform (Collider2D collider, out MovingPlatform movingPlatform) * { * return Instance.m_MovingPlatformCache.TryGetValue (collider, out movingPlatform); * }*/ public static bool TryGetPlatformEffector(Collider2D collider, out PlatformEffector2D platformEffector) { return(Instance.m_PlatformEffectorCache.TryGetValue(collider, out platformEffector)); }
// Start is called before the first frame update void Start() { theEffector = GetComponent <PlatformEffector2D>(); theEffector.rotationalOffset = 0f; waitTime = 0.0f; }
// Start is called before the first frame update void Start() { effector = GetComponent <PlatformEffector2D>(); layer = LayerMask.NameToLayer("Player"); // The name of the layer we want the platform to be semisolid for. Hardcoded as player lol }
private void Start() { pef = GetComponent <PlatformEffector2D>(); eN = GameObject.Find("Enemy").GetComponent <Enemy>(); pC = GameObject.Find("Player").GetComponent <PlayerController>(); }
private void Start() { effector = GetComponent <PlatformEffector2D>(); m_waitTime = waitTime; }
void Start() { player = GameObject.FindGameObjectWithTag("Player").transform; effector2D = GetComponent <PlatformEffector2D>(); _playerInput = player.GetComponent <Player.PlayerInput>(); }
void Start() { floor = GetComponent <PlatformEffector2D>(); }
private void Awake() { pEffector = GetComponent <PlatformEffector2D>(); }
public void Move(float move, bool crouch, bool jump) { bool JumpUnder = false; // ���� ���� �ִ��� �Ǻ�, �ɱ� ���� ���� �ʿ伺�� ���� if (!crouch) { if (Physics2D.OverlapCircle(m_CeilingCheck.position, k_CeilingRadius, m_WhatIsGround)) { crouch = true; } } if (m_Grounded) { if (m_JumpDisableCollider != null) { m_JumpDisableCollider.enabled = true; } // �ɱ� ���¶�� �Է��� ���� ��� if (crouch) { Collider2D promp = Physics2D.OverlapCircle(m_GroundCheck.position, k_GroundedRadius, m_WhatIsPlatform); if (promp && jump) { effector = promp.GetComponent <PlatformEffector2D>(); JumpUnder = true; StartCoroutine(VerticalJump()); } if (!m_wasCrouching)//ij���� ���� ���� ���·� �ٲ�� { m_wasCrouching = true; // �ɱ� ������ ���� �ݸ��� ���� Axis.position = new Vector3(Axis.position.x, Axis.position.y - 0.82f, Axis.position.z); OnCrouchEventTrue.Invoke();//�ɱ� ���·� �ٲٸ鼭 �̺�Ʈ ����. } if (m_CrouchDisableCollider != null) { m_CrouchDisableCollider.enabled = false; } // �ӵ� ���� move *= m_CrouchSpeed; } else { if (m_wasCrouching) { m_wasCrouching = false; // �ɱ� ���°� �ƴ� ��� �ݸ��� ���� Axis.position = new Vector3(Axis.position.x, Axis.position.y + 0.82f, Axis.position.z); if (m_CrouchDisableCollider != null) { m_CrouchDisableCollider.enabled = true; } OnCrouchEventFalse.Invoke();//���̵� ���·� �ٲٸ鼭 �κ�Ʈ ����. } } } // ���ϴ� �������� �ӷ��� �߰��� �̵� Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y); // �������� �ڿ������� m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing); // ���� ���� �پ��ְ� ���� �Է��� ���� ��� if (m_Grounded && jump && !JumpUnder && !isJumpCooldown) { // ���� ���� �� m_Grounded = false; //���� �پ��ִ����� �ǽð����� Ȯ�� m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); StartCoroutine(CooldownJump()); OnJumpEvent.Invoke(); if (m_JumpDisableCollider != null) { m_JumpDisableCollider.enabled = false; } if (m_CrouchDisableCollider != null) { m_CrouchDisableCollider.enabled = true; } } }
// Start is called before the first frame update void Start() { effector = GetComponent <PlatformEffector2D>(); rb = GetComponent <Rigidbody2D>(); }
private void Start() { myAudioSource = GetComponentInChildren <AudioSource>(); myPlatformEffector2D = GetComponent <PlatformEffector2D>(); CloseBody(); }
public void StartFall(PlatformEffector2D effector) { StartCoroutine(FallCoroutine(effector)); }
// Use this for initialization void Start() { lid = transform.Find("Lid").gameObject; lidPlatform = lid.GetComponent <PlatformEffector2D>(); }
public void Movement(Vector2 move, bool yMovement) { //check if were are going to hit something float distance = move.magnitude; //check if distance is greater than some minimal value if (distance > minMoveDistance) { //otherwise we're not going to check for collisions //Lets check if our rigid body is going to overlap with something in the next frame //we want to add some padding to the distance (a shell) to allow us to make sure we never get stuck in another collider int count = rb2d.Cast(move, contactFilter, hitBuffer, distance + shellRadius); hitBufferList.Clear(); //lets make sure we're not using old data for (int i = 0; i < count; i++) { //each entry from the array is going to get copied to the list PlatformEffector2D platform = hitBuffer[i].collider.GetComponent <PlatformEffector2D>(); if (!platform || (hitBuffer[i].normal == Vector2.up && velocity.y <= 0)) { hitBufferList.Add(hitBuffer[i]); } } //now we have a list of objects that are going to overlap our physics object's collider. //check the normal of each of those objects to determine the angle of the thing we're colliding with for (int i = 0; i < hitBufferList.Count; i++) { Vector2 currentNormal = hitBufferList[i].normal; if (gravityModifier >= 0 && currentNormal.y > minGroundNormalY) { //if the angle of the obj we're colliding with can be considered a piece of ground grounded = true; if (yMovement) { //add a variable for our ground normal groundNormal = currentNormal; currentNormal.x = 0; } } else if (gravityModifier <= 0 && currentNormal.y < minGroundNormalY) { //if the angle of the obj we're colliding with can be considered a piece of ground grounded = true; if (yMovement) { //add a variable for our ground normal groundNormal = -currentNormal; currentNormal.x = 0; } } //getting the diff between the velo and the cunormal and determining whether we need to subtract //from the velocity to make sure the player doesnt get stuck in something //hit their head on a sloped ceiling and continue a little bit float projection = Vector2.Dot(velocity, currentNormal); if (projection < 0) { //cancel out the velocity that would be stopped by the collision velocity = velocity - projection * currentNormal; } float modifiedDistance = hitBufferList[i].distance - shellRadius; distance = modifiedDistance < distance ? modifiedDistance : distance; } } //rb2d.position = rb2d.position + move.normalized * distance; transform.position = transform.position + new Vector3(move.normalized[0], move.normalized[1], 0) * distance; }
private void Start() { effector = GetComponent <PlatformEffector2D>(); }
public float waitTime; //time between down arrow pressed void Start() { effector = GetComponent <PlatformEffector2D>(); //initializes effector }