在我的游戏中,每隔几秒打印一个对象。
但我的浮动值出错了。这是我的代码:
grassBarn.transform.position = new Vector3(43, 12, 0);
出现这样的错误
Assets / scripts / gameplay / Classname.cs(44,62):错误CS1502:`UnityEngine.Vector3.Vector3(float,float,float)'的最佳重载方法匹配有一些无效的参数
有时喜欢这个
Assets / scripts / gameplay / Classname.cs(44,62):错误CS1503:参数#2无法将双表达式转换为float类型
谢谢!
答案 0 :(得分:1)
Vector3类使用浮点值。
使用C#编程时,必须使用f
值并指定小数,以告诉编译器您希望它们是浮点值。
我建议用这个:
grassBarn.transform.position = new Vector3(43f, 12f, 0f);