اذهب إلى المحتوى

السؤال

نشر (معدل)

بدأت في تخصص الالعاب علي ادراك ووصلت الي مرحلة GUIالمشكلة هي انه يعطيني من وقتها خطأ ولا اجد اي حل

وهذا هو الكود 2d

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playercontroler : MonoBehaviour
{
    public float speed;
    public SpriteRenderer sr;
    public Rigidbody2D rb;
    public float jump;
    int health;
    int score;
    public Animator anim;
    public Text healthText;
    public Text scoreText;


    // Start is called before the first frame update
    void Start()
    {
        health = 100;
        healthText.text = "health:" + health + "%";
        scoreText.text = "score: " + score  ;

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetAxis("Jump") > 0)
            rb.velocity = new Vector2(0, jump);
        anim.SetFloat("Speed", Mathf.Abs(rb.velocity.x));
    }
    private void FixedUpdate()
    {
        if (Input.GetAxis("Horizontal") > 0)
        {
            //transform.Translate(speed, 0, 0);
            rb.velocity = new Vector2(speed * Input.GetAxis("Horizontal"), rb.velocity.y);

            sr.flipX = false;
        }
        else if (Input.GetAxis("Horizontal") < 0)
        {
            rb.velocity = new Vector2(speed * Input.GetAxis("Horizontal"), rb.velocity.y);
            sr.flipX = true;
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("health"))
        {
            health += 10;
            healthText.text = "health:" + health + "%";

            Destroy(collision.gameObject);

        }
        else if (collision.CompareTag("score"))
        {
            score += 10;
            Destroy(collision.gameObject);
            scoreText.text = "score: " + score;


        }
        else if (collision.CompareTag("Enemy"))
        {
            if (transform.position.y > collision.transform.position.y)
            {
                Destroy(collision.gameObject);
            }
            else
            {
                health -= 10;
                healthText.text = "health:" + health + "%";

            }
        }
    }
}

وهذه الرسائل

Library\PackageCache\com.unity.2d.common@4.1.0\Runtime\InternalBridge\InternalEngineBridge.cs(21,35): error CS1061: 'SpriteRenderer' does not contain a definition for 'IsUsingDeformableBuffer' and no accessible extension method 'IsUsingDeformableBuffer' accepting a first argument of type 'SpriteRenderer' could be found (are you missing a using directive or an assembly reference?)

Invalid serialized file header. File: "VirtualArtifacts/Primary/ada555936059fa149bb48537842ee230".
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[])

Unknown error occurred while loading 'Library/Artifacts/f2/f27b79827eb6ce6ac46b0f92687c2a6e'.
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[])

Could not load Packages/com.unity.timeline/Editor/StyleSheets/Extensions/common.uss
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[])

Invalid serialized file header. File: "VirtualArtifacts/Primary/e98085123be873947970c4f10099a39a".
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[])

Unknown error occurred while loading 'Library/Artifacts/35/35c86656bde22d12ad98ab8a3a14d6dc'.
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[])

Could not load Packages/com.unity.timeline/Editor/StyleSheets/Extensions/light.uss
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[])

Assets\script\playercontact.cs(1,27): error CS1003: Syntax error, '(' expected

Assets\script\playercontact.cs(1,27): error CS1026: ) expected

Assets\script\playercontact.cs(2,1): error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Assets\script\playercontact.cs(3,1): error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

All compiler errors have to be fixed before you can enter playmode!
UnityEditor.SceneView:ShowCompileErrorNotification ()

Assets\script\playercontact.cs(15,12): error CS0246: The type or namespace name 'Text' could not be found (are you missing a using directive or an assembly reference?)

 

تم التعديل في بواسطة Hassan Hedr
تنسيق الشيفرة

Recommended Posts

لا توجد أي إجابات على هذا السؤال بعد

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...