我得到这个错误CS1061:'Rigidbody2D'不包含'velociy'的定义]]

问题描述 投票:0回答:1

这里是完全错误,我对它的出现位置或解决方法感到困惑error CS1061: 'Rigidbody2D' does not contain a definition for 'velociy' and no accessible extension method 'velociy' accepting a first argument of type 'Rigidbody2D' could be found (are you missing a using directive or an assembly reference?)

这是我的代码,我正在关注this教程。请帮忙。我是Unity新手,白天和黑夜都在这款游戏上度过。一直工作到最新版本的代码

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

public class PlayerController : MonoBehaviour
{

    public float moveSpeed;
    public float jumpForce;

    private Rigidbody2D myRigidbody;

    public bool grounded;
    public LayerMask whatIsGround;

    private Collider2D myCollider;

    private Animator myAnimator;

    // Start is called before the first frame update
    void Start()
    {
        myRigidbody = GetComponent<Rigidbody2D>();

        myCollider = GetComponent<Collider2D>();

        myAnimator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {

        grounded = Physics2D.IsTouchingLayers(myCollider, whatIsGround);

        myRigidbody.velocity = new Vector2(moveSpeed, myRigidbody.velocity.y);

        if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
        {

            if (grounded)
            {
                myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce);

            }
        }

        myAnimator.SetFloat ("Speed", myRigidbody.velociy.x);
        myAnimator.SetBool ("Grounded", grounded);
    }
}
    

这里完全错误Im在发生位置或如何解决时感到困惑,错误CS1061:'Rigidbody2D'不包含'velociy'的定义,并且没有可访问的扩展方法'velociy'接受第一个...”>

c# unity3d
1个回答
0
投票
这只是一个错字,将velociy更改为velocity,您就可以开始了。
© www.soinside.com 2019 - 2024. All rights reserved.