123/Assets/Scripts/PlayerController.cs

33 lines
790 B
C#
Raw Normal View History

2026-01-27 01:41:07 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// <20><><EFBFBD><EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> 'PlayerCtrller'<27><> <20><>Ȯ<EFBFBD><C8AE> <20><>ġ<EFBFBD>ؾ<EFBFBD> <20>մϴ<D5B4>.
public class PlayerController : MonoBehaviour
{
private Rigidbody playerRigidbody;
public float speed = 8f;
void Start()
{
playerRigidbody = GetComponent<Rigidbody>();
}
void Update()
{
float xInput = Input.GetAxis("Horizontal");
float zInput = Input.GetAxis("Vertical");
float xSpeed = xInput * speed;
float zSpeed = zInput * speed;
Vector3 newVelocity = new Vector3(xSpeed, 0f, zSpeed);
playerRigidbody.linearVelocity = newVelocity;
}
public void Die()
{
FindObjectOfType<GameManager>().EndGame();
gameObject.SetActive(false);
}
}