Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

I have a problem with my code please help

$
0
0
Update has an error which is "The body of 'movement.Update()' cannot be an iterator block because void is not an iterator type" it repeats that message(minus the double quotes) 4 times any help would be welcome using System.Collections; using System.Collections.Generic; using UnityEngine; public class movement : MonoBehaviour { // Use this for initialization void Start () { Cursor.lockState = CursorLockMode.Locked; } // Update is called once per frame void Update () { float Horizontal = Input.GetAxis("Horizontal"), Vertical = Input.GetAxis("Vertical");//this gets the wasd and arrow key input transform.Translate(Horizontal * Time.deltaTime * 5, 0f, Vertical * Time.deltaTime * 5);//this moves the player float MouseX = Input.GetAxis("Mouse X"), MouseY = Input.GetAxis("Mouse Y");//gets the mouse positino transform.Rotate(-MouseY,MouseX,0);//rotates the player as they move the mouse Vector3 playerRot = transform.rotation.eulerAngles; Vector3 playerPos = new Vector3(transform.position.x, 1f, transform.position.z); transform.position = playerPos; if (Input.GetKey(KeyCode.Return)) { if (Cursor.lockState == CursorLockMode.Locked) { Cursor.lockState = CursorLockMode.None; } else if (Cursor.lockState == CursorLockMode.None) { Cursor.lockState = CursorLockMode.Locked; yield return new WaitForSeconds(0.1f); } } } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class movement : MonoBehaviour { // Use this for initialization void Start () { Cursor.lockState = CursorLockMode.Locked; } // Update is called once per frame void **Update** () { float Horizontal = Input.GetAxis("Horizontal"), Vertical = Input.GetAxis("Vertical");//this gets the wasd and arrow key input transform.Translate(Horizontal * Time.deltaTime * 5, 0f, Vertical * Time.deltaTime * 5);//this moves the player float MouseX = Input.GetAxis("Mouse X"), MouseY = Input.GetAxis("Mouse Y");//gets the mouse positino transform.Rotate(-MouseY,MouseX,0);//rotates the player as they move the mouse Vector3 playerRot = transform.rotation.eulerAngles; Vector3 playerPos = new Vector3(transform.position.x, 1f, transform.position.z); transform.position = playerPos; if (Input.GetKey(KeyCode.Return)) { if (Cursor.lockState == CursorLockMode.Locked) { Cursor.lockState = CursorLockMode.None; } else if (Cursor.lockState == CursorLockMode.None) { Cursor.lockState = CursorLockMode.Locked; yield return new WaitForSeconds(0.1f); } } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>