Partage
  • Partager sur Facebook
  • Partager sur Twitter

problème unity

7 mai 2020 à 10:28:56

bonjour je suis en train de creer un platformer mais j'ai un pb avec les vecteurs serait'il possible de m'aider merci d'avance

voila le code :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class new_script : MonoBehaviour
{
    float x = 0.0f, y = 0.0f, z = 0.0f;
    Vector3 firstLvl = new Vector3(4.0f, -3.8f, 0.0f);
    Vector3 position = new Vector3(0.0f, 0.0f, 0.0f);

    void Start()
    {
    	
    }

    void Update () 
    {
        position = transform.position;
        if(position == firstLvl) {
            print("ok");
        }

        //player moving
        if (Input.GetKey(KeyCode.UpArrow))
        {
            y = 0.1f;
            transform.Translate(x, y, z);
            y = 0.0f;
        } else if (Input.GetKey(KeyCode.DownArrow))
        {
            y = -0.1f;
            transform.Translate(x, y, z);
            y = 0.0f;
        } else if (Input.GetKey(KeyCode.RightArrow))
        {
            x = 0.1f;
            transform.Translate(x, y, z);
            x = 0.0f;
        } else if (Input.GetKey(KeyCode.LeftArrow))
        {
            x = -0.1f;
            transform.Translate(x, y, z);
            x = 0.0f;
        }
        
    }
}



  • Partager sur Facebook
  • Partager sur Twitter
13 mai 2020 à 12:13:36

Quel est ton problème?

Quel est le résultat actuel? Le résultat attendu?

  • Partager sur Facebook
  • Partager sur Twitter
14 mai 2020 à 15:38:33

en gros je souhaiterais savoir si deux vecteurs sont égaux

et quand je change firstLVL (0.0f, 0.0f, 0.0f) je n'ais pas le message OK comme il est sensée etre

-
Edité par TidianDelage1 14 mai 2020 à 15:40:15

  • Partager sur Facebook
  • Partager sur Twitter