C# Assets/sucriptusu/movement/onflor.cs(23,13):错误CS0120:非静态字段、方法或属性需要对象引用';zoom.upZoom';

C# Assets/sucriptusu/movement/onflor.cs(23,13):错误CS0120:非静态字段、方法或属性需要对象引用';zoom.upZoom';,c#,C#,所以我试着让这段代码运行,但它询问了一些关于静态的问题,我真的不明白。任何帮助都会让我高兴:)。 基本上我想让你每次跳的时候,你的跳高都会更低。 上面的那个错误出现了,老实说,我(甚至在搜索了一点之后)不知道它是什么意思 using System.Collections; using System.Collections.Generic; using UnityEngine; public class zoom : MonoBehaviour { // Start is called

所以我试着让这段代码运行,但它询问了一些关于静态的问题,我真的不明白。任何帮助都会让我高兴:)。 基本上我想让你每次跳的时候,你的跳高都会更低。 上面的那个错误出现了,老实说,我(甚至在搜索了一点之后)不知道它是什么意思

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class zoom : MonoBehaviour
{
    // Start is called before the first frame update
    public float zoomSpeed = 5f;
    public float upZoom = 20f;
    public bool flor = false;
    public float jumpamount = 5f;
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        Jump();
        Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
        transform.position += movement * Time.deltaTime * zoomSpeed;
    }   
    void Jump()
    {
        if (Input.GetButtonDown("Jump") && flor == true);
        {
            upZoom = (upZoom - jumpamount);
            gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, upZoom), ForceMode2D.Impulse);  
        }
    }
} 

问题是您在
zoom.upZoom=20f中使用的
zoom
未初始化(即
zoom=new zoom()
)或类似内容。它必须在构造函数中初始化,或者必须是静态变量。C#!=UnityScript。UnityScript是为Unity创建的JavaScript派生。初始化的确切含义是什么?初始化的确切含义是什么?我对c#和unity非常陌生。缩写的确切含义是什么?我对c#和unity很陌生。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class onflor : MonoBehaviour
{
    GameObject mouseplayerreal;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        mouseplayerreal = gameObject.transform.gameObject;
    }
    private void OnCollisionEnter2D(Collision2D collision) 
    {
        if (collision.collider.tag == "Guroundo")
        {
            zoom.upZoom = 20f;

        }
    }
    private void OnCollisionExit2D(Collision2D collision)
    {
            if (collision.collider.tag == "Guroundo")
            {

            }

        }
    }