Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Pls Help

Discussion in 'Scripting' started by haydenthekid, Oct 9, 2020.

  1. haydenthekid

    haydenthekid

    Joined:
    Oct 8, 2020
    Posts:
    19
    The error is cs1014 which means i don't have a get or set assessor
    What is a set assessor.Error on lines 45,14,2,41,30,29
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. public class Player1 : MonoBehaviour
    4. {
    5.     bool jump = false;
    6.     public float speed = 5f;
    7. private float movement = 0f;
    8. private Rigidbody2D rigidBody;
    9. public float jumpSpeed = 8f;
    10.  
    11. // Use this for initialization
    12. void Start
    13. {
    14.     rigidBody = GetComponent<Rigidbody2D>();
    15. }
    16. // Update is called once per frame
    17. void Update()
    18. {
    19.             movement = Input.GetAxis("Horizontal");
    20.     if (movement > 0f)
    21.     {
    22.         rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    23.     }
    24.     else if (movement < 0f)
    25.     {
    26.         rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    27.     }
    28.     else
    29.     {
    30.         rigidBody.velocity = new Vector2(0, rigidBody.velocity.y);
    31.     }
    32.     movement = Input.GetAxis("Horizontal");
    33.     if (movement > 0f)
    34.     {
    35.         rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    36.     }
    37.     else if (movement < 0f)
    38.     {
    39.         rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    40.     }
    41.     else
    42.     {
    43.         rigidBody.velocity = new Vector2(0, rigidBody.velocity.y);
    44.     }
    45. }
    46.  
    47.  
     
  2. Meishin

    Meishin

    Joined:
    Apr 12, 2019
    Posts:
    26
    Hi @haydenthekid, i would suggest you follow a basic tutorial to get started :)

    For example ;


    Ps : 1) You didn't close your class bracket 2) Your update function is equivalent to :
    Code (CSharp):
    1. // Update is called once per frame
    2. void Update()
    3. {
    4.     movement = Input.GetAxis("Horizontal");
    5.     rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    6. }
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,741
    Stop spamming new threads for the same code. When you fix one problem, and then have errors still, it'll be much easier to keep track of things.

    Second, as I advised you in the previous thread, copy and paste the actual errors you're getting. The errors have lots of information in them, and when you try to paraphrase them, you're going to lose that information, and it makes it much harder for us to help you.