Answer the question
In order to leave comments, you need to log in
Why doesn't scripting work?
Wrote the script for character movement:
using UnityEngine;
public class Moving : MonoBehaviour {
public float Speed = 0.5f;
private float Horisontal, Vertical;
void Update ()
{
Horisontal = Input.GetAxis("Horisontal") * Speed;
Vertical = Input.GetAxis("Vertical") * Speed;
transform.Translate(Horisontal, 0, Vertical);
}
}
Answer the question
In order to leave comments, you need to log in
And why did you create your exact same axes if the unit already has Horizontal and Vertical out of the box? And by the way, yes, you have a typo in the title, it will be correct through the letter z. Are there any errors in the console? Have you tried running it on an empty stage with a cube? Is the script enabled in the inspector? GameObject not marked as static? At worst, you can try using the buttons directly:
using UnityEngine;
public class Moving : MonoBehaviour
{
public float Speed = 0.5f;
private void Update()
{
float horizontal = Input.GetKey(KeyCode.A) ? -Speed : Input.GetKey(KeyCode.D) ? Speed : 0;
float vertical = Input.GetKey(KeyCode.S) ? -Speed : Input.GetKey(KeyCode.W) ? Speed : 0;
transform.Translate(horizontal, 0, vertical);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question