Skip to content

Instantly share code, notes, and snippets.

@vjgrayman
Last active June 17, 2019 20:49
Show Gist options
  • Save vjgrayman/e7702fdf10cf2ee4386a5ab7763e5f8a to your computer and use it in GitHub Desktop.
Save vjgrayman/e7702fdf10cf2ee4386a5ab7763e5f8a to your computer and use it in GitHub Desktop.
SimpleMovement using defgault Input Keys, and Control Speed #CSharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[SerializeField]
private float _speed;
[SerializeField]
private float _horizontalInput;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
_horizontalInput = Input.GetAxis("Horizontal");
transform.Translate(new Vector3(_horizontalInput,0,0) * _speed * Time.deltaTime);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment