Ошибка CS0266: Cannot implicitly convert type 'double' to 'float'
Попытался сделать что-бы камера следила за персонажем по X и Y но при этом была на 2.49 выше центра персонажа.
using UnityEngine;
public class CamMove : MonoBehaviour
{
public Transform player;
void Start()
{
player = GameObject.FindGameObjectWithTag("Player").transform;
}
void Update()
{
float camY = player.transform.position.y+2.49;
transform.position = new Vector2 (player.transform.position.x, camY);
}
}
Выдаёт ошибку: error CS0266: Cannot implicitly convert type 'double' to 'float'. An explicit conversion exists (are you missing a cast?) Буду благодарен каждой попытке помочь.
Ответы (1 шт):
Автор решения: animagnoa
→ Ссылка
добавьте f для литерала 2.49
float camY = player.transform.position.y+2.49f;