Проблема private void OnTriggerEnter2D(Collider2D collision)
Проблема заключается что Unity выдает такую ошибки
1.Type '' already defines a member called 'OnTriggerEnter2D' with the same parameter types 2.namespace cannot directly contain members such as fields or methods
Не могли бы пожалуйста подсказать в чем заключается проблема
public float speed;
public float jumpForce;
private float moveInput;
private bool facingRight = true;
private Rigidbody2D rb;
private bool isGrounded;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
private int extraJumps;
public int extraJumpsValue;
private SpriteRenderer rend;
private bool canHide = false;
private bool hiding = false;
private void Start () {
rend = GetComponent<SpriteRenderer>();
extraJumps = extraJumpsValue;
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate () {
isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput*speed, rb.velocity.y);
if (facingRight == false && moveInput > 0) {
Flip();
} else if (facingRight == true && moveInput < 0) {
Flip();
}
if (!hiding) {
rb.velocity = new Vector2(moveInput, rb.velocity.y);
} else {
rb.velocity = Vector2.zero;
}
}
void Flip () {
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
private void Ju () {
if (isGrounded == true) {
extraJumps = extraJumpsValue;
}
if (Input.GetKeyDown(KeyCode.J) && extraJumps > 0) {
rb.velocity = Vector2.up*jumpForce;
extraJumps--;
} else if (Input.GetKeyDown(KeyCode.UpArrow) && extraJumps == 0 && isGrounded == true) {
rb.velocity = Vector2.up*jumpForce;
}
}
private void Update () {
if (canHide == true && Input.GetKey("F")) {
Physics2D.IgnoreLayerCollision(8, 9, true);
rend.sortingOrder = 0;
hiding = true;
} else {
Physics2D.IgnoreLayerCollision(8, 9, false);
rend.sortingOrder = 2;
hiding = false;
}
}
private void OnTriggerEnter2D (Collider2D collision) {
if (collision.gameObject.name.Equals("HideElement")) {
canHide = true;
}
}
private void OnTriggerEnter2D (Collider2D collision) {
if (collision.gameObject.name.Equals("HideElement")) {
canHide = false;
}
}