Quantcast
Viewing all articles
Browse latest Browse all 99

error CS0664: Literal of type double cannot be implicitly converted to type `float'. Add suffix `f' to create a literal of this type

Can anybody please tell me what this error means? Well here is my script. Please correct any other mistakes I made. using UnityEngine; using System.Collections; [RequireComponent(typeof(PlayerPhysics))] public class PlayerController : MonoBehaviour { public float speed = 8; public float acceleration = 12; private float currentSpeed; private float targetSpeed; private Vector2 amountToMove; private PlayerPhysics playerPhysics; // Use this for initialization void Start () { playerPhysics = GetComponent(); } // Update is called once per frame void Update () { targetSpeed = Input.GetAxisRaw ("Horizontal") * speed; currentSpeed = IncrementTowards (currentSpeed, targetSpeed, acceleration); } private float IncrementTowards(float n, float target, float speed) { if (n == target) { return 0.0; //this is the line it says the error was on. } else { float dir = Mathf.Sign (target - n); n += Time.deltaTime * dir; return (dir == Mathf.Sign (target - n)) ? n : target; } } }

Viewing all articles
Browse latest Browse all 99

Trending Articles