Hello,
I’m having some trouble with the code below. I’m trying to set up the vertical movement of a gameObject. The problem is, when I press ‘S’, the gameobject moves once, then stops. I thought that putting the input check inside the update loop would have it called once per frame, thereby creating continuous movement. Any help would be appreciated!
using UnityEngine;
using System.Collections;
public class PlayerPaddle : MonoBehaviour
{
public int speed;
// Use this for initialization
void Start ()
{
speed = 100;
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.S))
{
transform.Translate(0, -speed * Time.deltaTime, 0);
}
}
}