Search Unity

Survival Shooter Script Error(solved)

Discussion in 'Getting Started' started by hanghanghappy, Aug 14, 2017.

  1. hanghanghappy

    hanghanghappy

    Joined:
    Aug 10, 2017
    Posts:
    4
    When I am working on this project following the official tutorial on the Player Character Part , it said this in the error.

    Assets/Scripts/Player/PlayerMovement.cs(19,8): error CS1525: Unexpected symbol `anim'

    I wonder what is happening ? I follow every steps in the tutorial but still get this error.

    This is the script
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class PlayerMovement : MonoBehaviour
    4. {
    5.     public float speed = 6f;            // The speed that the player will move at.
    6.  
    7.     Vector3 movement;                   // The vector to store the direction of the player's movement.
    8.     Animator anim;                      // Reference to the animator component.
    9.     Rigidbody playerRigidbody;          // Reference to the player's rigidbody.
    10.     int floorMask;                      // A layer mask so that a ray can be cast just at gameobjects on the floor layer.
    11.     float camRayLength = 100f;          // The length of the ray from the camera into the scene.
    12.  
    13.     void Awake()
    14.     {
    15.         // Create a layer mask for the floor layer.
    16.         floorMask = LayerMask.GetMask ("Floor")
    17.  
    18.         // Set up references.
    19.         anim = GetComponent<Animator>();
    20.         playerRigidbody = GetComponent<Rigidbody>();
    21.     }
    22.  
    23.  
    24.     void FixedUpdate()
    25.     {
    26.         // Store the input axes.
    27.         float h = Input.GetAxisRaw("Horizontal");
    28.         float v = Input.GetAxisRaw("Vertical");
    29.  
    30.         // Move the player around the scene.
    31.         Move(h, v);
    32.  
    33.         // Turn the player to face the mouse cursor.
    34.         Turning();
    35.  
    36.         // Animate the player.
    37.         Animating(h, v);
    38.     }
    39. }
    Please help me with this:(
     
  2. hanghanghappy

    hanghanghappy

    Joined:
    Aug 10, 2017
    Posts:
    4
    I solved it , nevermind