-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mover.cs
34 lines (29 loc) · 828 Bytes
/
Mover.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
29
30
31
32
33
34
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mover : MonoBehaviour
{
[SerializeField] float moveSpeed=56.28f;
// Start is called before the first frame update
void Start()
{
PrintInstructions();
}
// Update is called once per frame
void Update()
{
MovePlayer();
}
void PrintInstructions()
{
Debug.Log("Welcome to the game");
Debug.Log("Use arrow keys to move your player");
Debug.Log("Don't hit the walls");
}
void MovePlayer()
{
float zValue = Input.GetAxis("Horizontal")* Time.deltaTime* moveSpeed;
float xValue = Input.GetAxis("Vertical")* Time.deltaTime* moveSpeed;
transform.Translate(xValue,0,zValue);
}
}