Files
GameDevTVObstacleDodge/Assets/Scripts/Mover.cs

34 lines
865 B
C#
Raw Normal View History

2026-01-08 16:50:20 +00:00
using UnityEngine;
public class Mover : MonoBehaviour
{
[SerializeField] float moveSpeed = 5f;
2026-01-09 10:41:51 +00:00
[SerializeField] Camera mainCamera;
2026-01-08 16:50:20 +00:00
// 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);
}
}