Hi
I have problem with understanding why I get an Assets/Scripts/cubeMove.cs(32,17): error CS0029: Cannot implicitly convert type float' to bool’
using UnityEngine;
using System.Collections;
public class cubeMove : MonoBehaviour {
public int playerSpeed;
public int playerTurnSpeed;
private Transform myPlayerObject;
// Use this for initialization
void Start () {
playerSpeed = 5;
playerTurnSpeed = 5;
myPlayerObject = transform;
myPlayerObject.position = new Vector3(2,1,2);
}
// Update is called once per frame
void Update () {
myPlayerObject.Translate(Vector3.right * Input.GetAxis("Horizontal") * playerSpeed * Time.deltaTime);
myPlayerObject.Translate(Vector3.forward * Input.GetAxis("Vertical") * playerSpeed * Time.deltaTime);
if(Input.GetAxis("Vertical"))
{
myPlayerObject.Rotate(Vector3.forward * playerTurnSpeed * Time.deltaTime);
}
}
}
My if-statement, where the error occurs, does the same as the one below (or is supposed to !), but they don’t get an error :
void Update ()
{
if(Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
}
Unity’s Translate Rotate tutorial
Would someone be so and explain ?
Also, should I stop using the Input Manager for movement and instead use: Input.GetKey(KeyCode.SomeKey
) ?