I Dont know what this error means and it isnt an issue the guy in the video im watching is having.
I am making a 2d platformer, and am trying to get the movement working, but I'm getting an error that doesnt show up in the video and i cant figure out why.
Here is the error message:
error CS1061: 'float' does not contain a definition for 'GetAxis' and no accessible extension method 'GetAxis' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?)
and here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float speed;
private float move;
private Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
move.GetAxis("Horizontal");
rb.velocity = new Vector2(speed * move, rb.velocity.y);
}
}
3 Replies
Well, the error is quite self-explanatory
move
is of type float
Type float
doesn't have a .GetAxis()
methodits likely you have misread the video, im sure you meant to assign Input.GetAxis to move
yeah im dumb. alright thanks.