Re: son qui est coupé au mileu
Publié : 23 Mai 2023 08:34
j'ai rien compris
Le forum de la communauté francophone d'Unity
https://www.unity3d-france.com/unity/phpBB3/
https://www.unity3d-france.com/unity/phpBB3/viewtopic.php?f=25&t=18921
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class PlayerMovment : MonoBehaviour
{
public Rigidbody2D MyRigidBody;
public float flapStength;
public Logic logic;
public bool birdIsAlive = true;
// Start is called before the first frame update
void Start()
{
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<Logic>();
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Space) && birdIsAlive)
{
MyRigidBody.velocity = Vector2.up * flapStength;
}
if(transform.position.y > 15 || transform.position.y < -14)
{
birdIsAlive = false;
logic.gameOver();
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
birdIsAlive = false;
logic.gameOver();
}
private void
}
Code : Tout sélectionner
//Si l'oiseau est vivant alors gameOver est possible, sinon, on ne peut entrer dans cette condition
if(birdIsAlive && (transform.position.y > 15 || transform.position.y < -14))
{
birdIsAlive = false;
logic.gameOver();
}