纳金网

标题: 可用Vector3.up,但不能用Vector3(0,1,0)? [打印本页]

作者: 雅雅    时间: 2013-2-28 00:24
标题: 可用Vector3.up,但不能用Vector3(0,1,0)?
在脚本中能使用可以用Vector3.up等,但不能用Vector3(0,1,0)等,提示错误为:
error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

代码如下,最后一行出错
if(Input.GetMouseButtonDown(0)) {
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    RaycastHit hitInfo;
    if (Physics.Raycast(ray.origin, ray.direction,out hitInfo)) {
      Vector3 targetPosition = hitInfo.point;
      transform.position = targetPosition + Vector3(0,1.0f,0);//这里如果用Vector3.up就不会出错
    }
  }
是什么原因呢?不都是Vector3类型么

作者: 狂风大尉    时间: 2013-2-28 23:20
希望在新的一年里专心的学习好Unity!





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5