emre1035
Femtopat
- Katılım
- 20 Nisan 2023
- Mesajlar
- 40
Daha fazla
- Cinsiyet
- Erkek
Merhaba. Ben bir oyun yapıyorum. Ancak mobil için yapıyorum. Ama beni kullandığım kaynak bilgisayar için. O yüzden klavye tuşları ile yapılıyor. Ben butonlarla yapmak istiyorum. Bunu nasıl yapabilirim?
Kod:
Kod:
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerController : MonoBehaviour
{
public float harakethızı = 10;
public float speed = 5f;
public float min_X, max_X;
void Start()
{
}
void Update()
{
MovePlayer();
}
void MovePlayer()
{
if (Input.GetAxisRaw("Horizontal") > 0f)
{
Vector3 temp = transform.position;
temp.x += speed * Time.deltaTime;
if (temp.x > max_X)
temp.x = max_X;
transform.position = temp;
}
else if (Input.GetAxisRaw("Horizontal") < 0f)
{
Vector3 temp = transform.position;
temp.x -= speed * Time.deltaTime;
if (temp.x < min_X)
temp.x = min_X;
transform.position = temp;
}
}
}
Son düzenleyen: Moderatör: