I cant use this for some reason, the error is
Assets/Scripts/Player.cs(15,14): error CS1624: The body of `Player.Update()' cannot be an iterator block because `void' is not an iterator interface type
Code vv
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public float playerSpeed = 10.0f;
private bool isJumping = false;
// Use this for initialization
void Start () {
transform.position = new Vector3(0, 1, -5);
}
// Update is called once per frame
void Update () {
transform.Translate(Vector3.right * Input.GetAxis("Horizontal") * Time.deltaTime * playerSpeed);
if (Input.GetKeyDown ("w") && isJumping==false)
{
print ("yo");
isJumping = true;
for(int i=1;i<=200;i++)
{
yield return new WaitForEndOfFrame();
transform.Translate(Vector3.up * Input.GetAxis ("Vertical") * Time.deltaTime);
if(Input.GetKeyUp("w"))
{
//break;
}
}
for(int i=200;i>=1;i--)
{
yield return new WaitForEndOfFrame();
transform.Translate(Vector3.down * Input.GetAxis ("Vertical") * Time.deltaTime);
}
print ("ayy");
isJumping = false;
}
}
} |