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 panelclicked = false;
private bool zıplamaYapabilir = true;
public Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (panelclicked == true)
{
horizontal = -Input.GetAxis("Horizontal");
rb.velocity = new Vector2(hız * horizontal, rb.velocity.y);
if (Input.GetKeyDown(KeyCode.W) && zıplamaYapabilir == true)
{
rb.AddForce(new Vector2(rb.velocity.x, zıplama));
zıplamaYapabilir = false;
}
}
}
private void OnCollisionStay2D(Collision2D other)
{
if (other.gameObject.CompareTag("yer"))
{
zıplamaYapabilir = true;
}
if (other.gameObject.CompareTag("flag"))
{
Destroy(other.gameObject);
}
}
private void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.CompareTag("yer"))
{
zıplamaYapabilir = false;
}
}
public void ControllerOpener()
{
panelclicked = true;
}
}
Bu kodu karakterime yolladım ama karakter yukarıda belirttiğim gibi bir kere zıplayıp yere değince bir daha zıplamıyor nasıl çözeceğim?