Unity5 engine error in code

Asked

Viewed 68 times

4

I was creating a code for the one game and in the end appeared some problems:

Assets/Scripts/Player/PlayerMovement.cs(63,23): error CS1547: Keyword `void' cannot be used in this context

Assets/Scripts/Player/PlayerMovement.cs(63,26): error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[', or `='

The code is like this:

void Turning ()
{
    Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit floorHit;

        if(Physics.Raycast(camRay, out floorHit,camRayLenght, floorMask) )

        {
            Vector3 playerToMouse = floorHit - transform.position;
            playerToMouse.y = of;

            Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
            playerRigidbody.MoveRotation(newRotation);
        }
         void Animating  (float h, float v);

        }

Evidência

  • Leandro, welcome to SOPT. This site is not a forum. If you haven’t done it yet, do the [tour] please. If any answers solved your problem, consider accepting it (marking it by clicking on the "v" below the score). Also remember to open another question for a new question/difficulty. :)

  • understood thanks , more still not fully solved my problem

  • You solved the errors of this question, didn’t you? As I said, this site is not a forum. If you have another question, open another question. If you want step-by-step help, I suggest looking for someone with an interest in helping you with [chat] (but honestly I don’t know if you already have enough reputation to join the chat - test to see, okay?) or another site. Good luck! :)

  • thank you Luiz Vieira

3 answers

3

You’re barely trying to define the animating function. First because you haven’t closed the previous one (Turning) and then because you have to open a block after the parameters. It looks like this:

void Turning () { 
  Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
  RaycastHit floorHit;
  if(Physics.Raycast(camRay, out floorHit,camRayLenght, floorMask) )
  {
    Vector3 playerToMouse = floorHit - transform.position;
    playerToMouse.y = of;
    Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
    playerRigidbody.MoveRotation(newRotation);
  }
}

void Animating  (float h, float v){
}

3


Error is in function

void Animating  (float h, float v);

Where the right would be for you to set her off void Turning ()

  • I’ll try to fix . Now another error has appeared

  • @Leandroyoshida It worked?

  • A part yes , but another error appeared , in Animating

  • @Leandroyoshida You can ask another question I’ll help you solve.

  • I want to send another print to show the problem better

0

Leandro,

I noticed that you put the letter O or instead of the number 0 in some lines, as for example is:

playerToMouse.y = of;

Of course, unless you have a variable with the name of

Browser other questions tagged

You are not signed in. Login or sign up in order to post.