Hola quiero que la esfera se mueva para la derecha y para la izquierda pero no se mueve. Este es mi codigo si alguien me pudiese ayudar se lo agradeceria.
using System.Collections;
using System.Collections.Generic; using UnityEngine;
public class moveorb : MonoBehaviour {
public KeyCode moveL;
public KeyCode moveR;
public float horizVel = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
GetComponent<Rigidbody> ().velocity = new Vector3(horizVel, 0, 4);
if (Input.GetKeyDown(moveL))
{
horizVel = -2;
StartCoroutine (StopSlide ());
}
if (Input.GetKeyDown(moveR))
{
horizVel = 2;
StartCoroutine (StopSlide ());
}
}
IEnumerator StopSlide()
{
yield return new WaitForSeconds (.5f);
horizVel = 0;
}
}