Hi!
I’m making a top-down 2d game. I have the code right. but the console keeps saying this(1. picture)
Here’s the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public float speed;
private Rigidbody2D myRigidbody;
private Vector3 change;
// Start is called before the first frame update
void Start () {
myRigidbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update() {
change = Vector3.zero;
change.x = Input.GetAxisRaw("Horizantal");
change.y = Input.GetAxisRaw("Vertical");
if(change != Vector3.zero)
{
MoveCharacter();
}
}
void MoveCharacter()
{
myRigidbody.MovePosition(
transform.position + change * speed * Time.deltaTime
);
}
}