unity脚本求助
#pragmastrictvarfk:GameObject=Find("cube");functionOnMouseDown(){fk.rigidbody.useGrav...
#pragma strict
var fk :GameObject=Find("cube");
function OnMouseDown (){
fk.rigidbody .useGravity ="ture";
print("ok");
}
咋错了?
错误:Assets/jiaoben/NewBehaviourScript.js(4,35): BCE0022: Cannot convert 'String' to 'boolean'. 展开
var fk :GameObject=Find("cube");
function OnMouseDown (){
fk.rigidbody .useGravity ="ture";
print("ok");
}
咋错了?
错误:Assets/jiaoben/NewBehaviourScript.js(4,35): BCE0022: Cannot convert 'String' to 'boolean'. 展开
1个回答
展开全部
fk.rigidbody .useGravity ="ture";改成fk.rigidbody .useGravity =true;
报错意思是不能把String类型转化成boolean类型。原型是fk.rigidbody .useGravity是boolean类型,你传入的“ture”是String类型了。注意boolean类型的true或者false都不能加双引号,否则就变成true或者false这个字符串了,其次你的true拼写错误了
报错意思是不能把String类型转化成boolean类型。原型是fk.rigidbody .useGravity是boolean类型,你传入的“ture”是String类型了。注意boolean类型的true或者false都不能加双引号,否则就变成true或者false这个字符串了,其次你的true拼写错误了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询