ColosusYEB
Öğrenci
- Katılım
- 10 Şubat 2023
- Mesajlar
- 55
- Çözümler
- 1
- Reaksiyon puanı
- 11
- Puanları
- 8
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class hareketbenim : MonoBehaviour
{
public float hız = 8f;
public float zıplama = 16f;
private float horizontal;
private bool zıplıyonmu;
public Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
horizontal = -Input.GetAxis("Horizontal");
rb.velocity = new Vector2(hız * horizontal, rb.velocity.y);
if (Input.GetKeyDown(KeyCode.W) && zıplıyonmu == false)
{
rb.AddForce(new Vector2(rb.velocity.x, zıplama));
}
}
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("yer"))
{
zıplıyonmu = false;
}
if (other.gameObject.CompareTag("flag"))
{
Destroy(other.gameObject);
}
}
private void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.CompareTag("yer"))
{
zıplıyonmu = true;
}
}
}
Kodum böyle. Yapmak istediğim şey şu: Bu karakter oyun başlamadan önce oyunun tanıtımı gibi bir panel açıkken veya oyun bitmişken panel kapanana kadar hareket etmesin istiyorum. Bunu nasıl yapabilirim?