Search Unity

Question Help with error CS1061

Discussion in 'Scripting' started by Bashersmasher34, May 24, 2020.

  1. Bashersmasher34

    Bashersmasher34

    Joined:
    May 24, 2020
    Posts:
    1
    I'm new to C# and have an error that I need some help with.

    Error message;

    Assets\Scripts\PlayerMovement.cs(30,47): error CS1061: 'Vector3' does not contain a definition for 'Y' and no accessible extension method 'Y' accepting a first argument of type 'Vector3' could be found (are you missing a using directive or an assembly reference?)


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerMovement : MonoBehaviour
    6. {
    7.     public float speed;
    8.     private Rigidbody2D myRigidbody;
    9.     private Vector3 change;
    10.     private Animator animator;
    11.  
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.         animator = GetComponent<Animator>();
    17.         myRigidbody = GetComponent<Rigidbody2D>();
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.         change = Vector3.zero;
    24.         change.x = Input.GetAxisRaw("Horizontal");
    25.         change.y = Input.GetAxisRaw("Vertical");
    26.         if(change != Vector3.zero)
    27.         {
    28.             MoveCharacter();
    29.             animator.SetFloat("moveX", change.x);
    30.             animator.SetFloat("moveY", change.Y);
    31.         }      
    32.     }
    33.  
    34.     void MoveCharacter()
    35.     {
    36.         myRigidbody.MovePosition(
    37.             transform.position + change * speed * Time.deltaTime
    38.         );
    39.     }
    40. }
     
  2. Cyber-Dog

    Cyber-Dog

    Joined:
    Sep 12, 2018
    Posts:
    352
    animator.SetFloat("moveY", change.Y);

    The Y is capital, change it to a lowercae y