简体   繁体   中英

(Unity3D) error CS1503: Argument 2: cannot convert from 'float' to 'UnityEngine.Space'

I'm trying to learn c# in unity and when I follow an old tutorial on using the mouse to look and move I get this error. It seems like unity has been greatly updated since then. I figured I can try and learn the c code anyway. Is there any simple way to make it work? I'm trying to move a ball around in first person view.

using UnityEngine;

public class Motion : MonoBehaviour
{

    
    public float speedx = .1f;
    

    void Update()
    {
        float movement = Input.GetAxis ("Vertical");
        movement *= Time.deltaTime;
        
        this.transform.Translate
        (Vector3.forward, movement);
        
        float xDirection = Input.GetAxis("Horizontal");
        
        Vector3 moveDirection = new Vector3(xDirection, 0.1f, movement);
        
        transform.position += moveDirection * speedx;
        
        
    }
}

(Vector3.forward , motion) 应该是 (Vector3.forward * movement)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM