Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Can someone please help me with 2d movement(no gravity) problems?

Discussion in 'Getting Started' started by Simiasdf, Mar 3, 2024.

  1. Simiasdf

    Simiasdf

    Joined:
    Feb 17, 2024
    Posts:
    5
    This is my Script(I copied it from a tutorial and tried to fix the errors):
    using System.Collections;
    using System.Collections.Genric;
    using UnityEngine;

    public class Movement : MonoBehavour
    {}



    public float moveSpeed;
    float SpeedX; speedY
    Rigidbody2D; rb





    Start()
    {
    rb = GetComponent<Rigidbody2D>();

    }


    void Update()
    {

    speedX = Input.GetAxisRaw("Horizontal") = moveSpeed;
    speedY = Input.GetAxisRaw("Vertical") = moveSpeed;
    rb.velocity = new Vector2(speedX, speedY);
    }
     
  2. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    2,017
    what do you think is wrong with it?

    (PS and please learn to use the code tags)
     
  3. Simiasdf

    Simiasdf

    Joined:
    Feb 17, 2024
    Posts:
    5
    it says error code CS8803 and wants me to enter safe mode
     
  4. Simiasdf

    Simiasdf

    Joined:
    Feb 17, 2024
    Posts:
    5
  5. Simiasdf

    Simiasdf

    Joined:
    Feb 17, 2024
    Posts:
    5
    I tried to copy a script from an other game, but something went wrong, a fatal error popped up and the file was broken, but I had a save from earlier today, so I only lost some progress in the script
     
  6. Simiasdf

    Simiasdf

    Joined:
    Feb 17, 2024
    Posts:
    5
  7. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    2,017
    so the class followed by {} followed by what is now random junk is not a hint? it even tells you which line it hates