Engine Unity5 error in code

4

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

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 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);

        }

    
asked by anonymous 19.05.2016 / 14:25

3 answers

3

Error is in function

void Animating  (float h, float v);

Where the correct one would be to set it out of void Turning ()

    
19.05.2016 / 14:45
3

You are trying to set the Animating function badly. Firstly because you have not 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){
}
    
19.05.2016 / 14:28
0

Leandro,

I noticed that you have put the letter O or rather the number 0 in some lines, for example:

playerToMouse.y = of;

Of course, unless you have a variable named

    
20.05.2016 / 21:15