33 lines
825 B
C#
33 lines
825 B
C#
using UnityEngine;
|
|
|
|
public class Mover : MonoBehaviour
|
|
{
|
|
[SerializeField] float moveSpeed = 5f;
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
PrintInstructions();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
MovePlayer();
|
|
}
|
|
|
|
void PrintInstructions()
|
|
{
|
|
Debug.Log("Welcome to the game!");
|
|
Debug.Log("Use WASD or Arrow keys to move the object.");
|
|
Debug.Log("Don't bump into objects.");
|
|
}
|
|
|
|
void MovePlayer()
|
|
{
|
|
float xValue = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
|
|
float zValue = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
|
|
float yValue = 0f;
|
|
transform.Translate(xValue, yValue, zValue);
|
|
}
|
|
}
|