- Home /
what did i do wrong?,what did I do wrong
I just wanna him move
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class movejogador : MonoBehaviour { public float Velocidade;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void Moviment () { float horizontal = Input.GetAxisRaw ("Horizontal");
float Vertical = Input.GetAxisRaw ("Vertical");
if (horizontal > 0 || horizontal < 0) {
transform.Translate (horizontal*Time.deltaTime*Velocidade,0,0);
}
if (Vertical > 0 || Vertical < 0) {
transform.Translate (Vertical*Time.deltaTime*Velocidade, 0, 0);
}
}
} ,unity can't play the game, I just made this script in a sprite
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class movejogador : MonoBehaviour { public float Velocidade;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void Moviment () { float horizontal = Input.GetAxisRaw ("Horizontal");
float Vertical = Input.GetAxisRaw ("Vertical");
if (horizontal > 0 || horizontal < 0) {
transform.Translate (horizontal*Time.deltaTime*Velocidade,0,0);
}
if (Vertical > 0 || Vertical < 0) {
transform.Translate (Vertical*Time.deltaTime*Velocidade, 0, 0);
}
}
}
Comment
Answer by Prastiwar · Jan 16, 2018 at 03:00 PM
You have nothing in Update method. Just put there this Moviment();
Your answer
![](https://koobas.hobune.stream/wayback/20220612150618im_/https://answers.unity.com/themes/thub/images/avi.jpg)