S
S
SirTSur2022-03-14 17:44:38
C++ / C#
SirTSur, 2022-03-14 17:44:38

How to solve error CS1520?

The code:

private OnCollisionEnter2D(Collision2D collision)
{
  if (collision.gameObject.tag == "Ground")
    isGrounded = true;
}

private OnCollisionExit2D(Collision2D collision)
{
  if (collision.gameObject.tag == "Ground")
    isGrounded = false;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
KraGen.Developer, 2022-03-14
@SirTSur

void should have been added

private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Ground")
isGrounded = true;
}

private void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.tag == "Ground")
isGrounded = false;
}

V
Vladimir Korotenko, 2022-03-14
@firedragon

you only return the value if the condition is met, add else or return by default.
and read the documentation there everything is written
https://docs.microsoft.com/ru-ru/dotnet/csharp/mis...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question