32 lines
739 B
C#
32 lines
739 B
C#
|
|
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()
|
|||
|
|
{
|
|||
|
|
gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
}
|