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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

MovementSpeed doesnt appear

Discussion in 'Scripting' started by lazarlakijugovic, Jul 11, 2022.

  1. lazarlakijugovic

    lazarlakijugovic

    Joined:
    Jul 10, 2022
    Posts:
    2
    So MovementSpeed doesnt appear in inspector and idk why, if somebody can help please do
    Here is the script:

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class NewBehaviourScript : MonoBehaviour
    5. {
    6.  
    7.     private float MovementSpeed = 10;
    8.  
    9.  
    10.     private void Start()
    11.     {
    12.  
    13.  
    14.  
    15.     }
    16.  
    17.     private void Update()
    18.     {
    19.         var movement = Input.GetAxis("Horizontal");
    20.         transform.position += new Vector3(movement, 0, 0) * Time.deltaTime * MovementSpeed;
    21.  
    22.  
    23.  
    24.     }
    25. }
    26.  
     
  2. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    238
    make MovementSpeed public. private fields do not show up in the inspector and aren't serialized (persisted).

    Also, this isn't a 2D question. It's a 'scripting' question.
     
  3. lazarlakijugovic

    lazarlakijugovic

    Joined:
    Jul 10, 2022
    Posts:
    2
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    I'll move your post to the scripting forum.