-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerMovement.cs
28 lines (21 loc) · 785 Bytes
/
PlayerMovement.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[SerializeField]
private float speed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
transform.Translate(new Vector3(horizontalInput, 0, 0) * speed * Time.deltaTime);
//to hard input for this the eaasiest built in unity wayu is to use tyhe axis horizontal key or vertical
//you could use an if statement for each direction but why bother
//this is an example of craziness - transform.Translate(new Vector3(1, 3, 4) * speed * Time.deltaTime);
}
}