Answer the question
In order to leave comments, you need to log in
Buttons in Unity, what are they, and how does it usually end?
Problem. Let's say I have a button, when pressed, each frame should execute the code:
this.transform.Translate(0, speed * Time.deltaTime, 0);
using UnityEngine;
public class Movement : MonoBehaviour
{
public float speed;
// Start is called before the first frame update
void Start()
{
}
public void Left()
{
this.transform.Translate(0, speed * Time.deltaTime, 0);
}
public void Right()
{
this.transform.Translate(0, -speed * Time.deltaTime, 0);
}
void Update()
{
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question