praca_magisterska/games/unity/magisterka_1/Assets/PlayerController.cs

20 lines
530 B
C#
Raw Normal View History

2025-08-02 19:47:47 +02:00
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public GameObject bulletPrefab;
public Transform shootPoint;
public float speed = 5f;
void Update()
{
float moveX = Input.GetAxis("Horizontal");
float moveY = Input.GetAxis("Vertical");
transform.position += new Vector3(moveX, moveY, 0) * speed * Time.deltaTime;
if (Input.GetKeyDown(KeyCode.Space))
{
Instantiate(bulletPrefab, shootPoint.position, Quaternion.identity);
}
}
}