C Sharp – die besten Beiträge

Fehler im Skript?

Ich probiere gerade ein eigenes Jump and Run Spiel zu Programmieren. Ich wollte eigentlich gerade testen ob ich jetzt mit Lehrtaste springen kann aber dann kahm dieser Error : Assets\Script\Charackter.cs(24,5): error CS8803: Top-level statements must precede namespace and type declarations.

So sieht mein Code aus : using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Charackter : MonoBehaviour

{

  public float speed = 5.0f;

   

  public Vector3 jump;

  public float jumpForce = 2.0f;

   

  public float jumpHeight = 7f;

  public bool isGrounded;

  private Rigidbody rb;

}

  // Start is called before the first frame update

  void Start()

  {

    speed = 5.0f;

    rb = GetComponent<Rigidbody>();

     

  }

  // Update is called once per frame

  void Update()

  {

    if (Input.GetKey(KeyCode.W))

    {

      transform.Translate(Vector3.forward * Time.deltaTime * speed);

    }

    if (Input.GetKey(KeyCode.S))

    {

      transform.Translate(-1 * Vector3.forward * Time.deltaTime * speed);

    }

    if (Input.GetKey(KeyCode.A))

    {

      transform.Rotate(0, -1, 0);

    }

    if (Input.GetKey(KeyCode.D))

    {

      transform.Rotate(0, 1, 0);

    }

  if (isGrounded)

  {

    if (Input.GetButtonDown("Jump"))

    {

      rb.AddForce(Vector3.up * jumpHeight);

    }

  }

  void OnCollisionEnter(Collision other)

  {

    if (other.gameObject.tag == "Ground")

    {

      isGrounded = true;

    }

  }

  void OnCollisionExit(Collision other)

  {

    if (other.gameObject.tag == "Ground")

    {

      isGrounded = false;

    }

  }

}

  Ich währe sehr Dankbar um Hilfe da ich nicht so viel Ahnung von diesem Thema habe.

Lg

C Sharp, Visual Studio, Unity

Probleme beim starten von mp4 Dateien mit C# Windows Forms App?

Wie es der Titel schon beschreibt habe ich Probleme damit .mp4 Dateien per Button mit meiner Windows Forms App zu starten.

Probiert habe ich es zb. schon hiermit:

private void materialButton18_Click(object sender, EventArgs e)
        {
            string filePath = @"C:\Program Files\VBC-Files\Backgrounds\NSFW\AlbedoXLupusNormal.mp4";
            if (!File.Exists(filePath))
            {
                MessageBox.Show("Please download the backgrounds first.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                System.Diagnostics.Process.Start(filePath);
            }
        }

Allerdings erhalte ich dann Fehler Meldungen wie diese hier: (Programm schmiert nach drücken des Buttons ab)

System.ComponentModel.Win32Exception: 'An error occurred trying to start process 'C:\Program Files\VBC-Files\Backgrounds\NSFW\AlbedoXLupusNormal.mp4' with working directory 'C:\Users\Anwender\source\repos\Votexs Background Changer\Votexs Background Changer\bin\Debug\net6.0-windows'. The specified executable is not a valid application for this OS platform.'

Ich habe auch schon versucht zb. von Windows Media Player den Pfad anzugeben, was nicht direkt in einem crash des Programms endet, allerdings öffnet sich dann halt einfach nichts.

System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Windows Media Player\wmplayer.exe", fileName);

Mit .exe Dateien habe ich dieses Problem nicht und verstehe nicht warum er bei .mp4 Dateien so faxen macht.

Ich bin für jegliche Hilfe sehr dankbar.

MP4, Datei, programmieren, C Sharp, Visual Studio

Meistgelesene Beiträge zum Thema C Sharp