public void OnCollisionEnter2D(Collision2D col) { if (PG.IsMode()) { if (col.gameObject.tag == "Player") { change = !change; } } }
public void OnCollisionEnter2D(Collision2D other) { if (PG.IsMode()) { if (other.gameObject.tag == "Enemy") { CGravity = !CGravity; } } }
void OnCollisionEnter2D(Collision2D col) { if (!PG.IsMode()) { if (col.gameObject.tag == "Player") { GameObject particle = Instantiate(break_particle); particle.transform.position = transform.position; this.gameObject.SetActive(false); } } }
// Update is called once per frame void Update() { playerGravity.Change(seconds); grounded = Physics2D.Linecast(transform.position, transform.position - transform.up * 0.55f, groundLayer); isGround = Physics2D.Linecast( transform.position, transform.position - transform.up * 1.6f, groundLayer); if (isGround && rigid2D.velocity.y <= 0) { if (Input.GetKeyDown(KeyCode.Space)) { jumpRes = true; } } else if (!grounded && 0 < jumpCount && playerGravity.IsMode()) { if (Input.GetKeyDown(KeyCode.Space)) { rigid2D.velocity = new Vector2(rigid2D.velocity.x, 8f); jumpCount--; } } if (grounded && jumpRes && playerGravity.IsMode()) { rigid2D.velocity = new Vector2(rigid2D.velocity.x, 10f); //Jump(); jumpRes = false; jumpCount = startJumpCount; } //大小ジャンプ if (Input.GetKey(KeyCode.Space) && rigid2D.velocity.y > 0.0f && playerGravity.IsMode() && !grounded) { rigid2D.gravityScale = 0.5f; } else { rigid2D.gravityScale = 1f; } key = 0; //左右移動 if (playerGravity.IsMode()) { totalTime += Time.deltaTime; seconds = totalTime; if (seconds >= resTime) { totalTime = resTime; } //Physics2D.gravity = yGravity; if (Input.GetKey(KeyCode.RightArrow)) { key = 1; leftFlag = false; } if (Input.GetKey(KeyCode.LeftArrow)) { key = -1; leftFlag = true; } if (Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.LeftArrow)) { rigid2D.velocity = new Vector2(0, rigid2D.velocity.y); } } else if (!playerGravity.IsMode()) { audioManager.AudioPlay(andou2); totalTime -= Time.deltaTime; seconds = totalTime; //Physics2D.gravity = xGravity; if (velocity.x < MaxGravitySpeed) { velocity += xGravity * Time.deltaTime; transform.Translate(velocity * Time.deltaTime); } } }