this is extremely frustrating, basically Input.GetAxisRaw only ever returns a 1 or -1. see my code below
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour
{
private BoxCollider2D boxCollider;
private Vector3 moveDelta;
private void Start()
{
boxCollider = GetComponent<BoxCollider2D>();
}
private void FixedUpdate()
{
float x = Input.GetAxisRaw("Horizontal");
float y = Input.GetAxisRaw("Vertical");
// Reset moveDelta
moveDelta = new Vector3(x,y,0);
// Swap sprite direction, whether you're going right or left
if(moveDelta.x > 0){
transform.localScale = Vector3.one;
}
else if(moveDelta.x < 0){
transform.localScale = new Vector3(-1,1,1);
}
//Make this thing move!
transform.Translate(moveDelta * Time.deltaTime);
Debug.Log(x);
Debug.Log(y);
}
}
Here are screenshots from the input settings, I haven't changed anything:
Please help, I am new to Unity. Could not find anything that work, the other related post was unanswered.