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?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float speed;
private Rigidbody2D myRigidbody;
private Vector3 change;
private Animator animator;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
myRigidbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
change = Vector3.zero;
change.x = Input.GetAxisRaw("Horizontal");
change.y = Input.GetAxisRaw("Vertical");
if(change != Vector3.zero)
{
MoveCharacter();
animator.SetFloat("moveX", change.x);
animator.SetFloat("moveY", change.Y);
}
}
void MoveCharacter()
{
myRigidbody.MovePosition(
transform.position + change * speed * Time.deltaTime
);
}
}