关于Unity的Vector3的问题

voidUpdate(){RaycastHithit;if(Input.GetMouseButtonDown(0)){Rayray=Camera.main.ScreenP... void Update()
{

RaycastHit hit;

if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);

if (Physics.Raycast (ray, out hit)) {
if (hit.collider.gameObject.name == "Plane") {

pointerObj.transform.position = hit.point;

}
else {

Vector3 A =new Vector3(hit.point.x,hit.collider.gameObject.transform.y,hit.point.z);
pointerObj.transform.position=A;
Debug.Log (hit.collider.gameObject.name);
Debug.Log(1111);

}
}
}

为什么
Vector3 A =new Vector3(hit.point.x,hit.collider.gameObject.transform.y,hit.point.z);
pointerObj.transform.position=A;
这报错呢?

Assets/Final IK/NavMeshExtension/Scripts/AgentController.cs(72,110): error CS1061: Type `UnityEngine.Transform' does not contain a definition for `y' and no extension method `y' of type `UnityEngine.Transform' could be found (are you missing a using directive or an assembly reference?)

2.Assets/Final IK/NavMeshExtension/Scripts/AgentController.cs(72,124): error CS1502: The best overloaded method match for `UnityEngine.Vector3.Vector3(float, float, float)' has some invalid arguments
3. Assets/Final IK/NavMeshExtension/Scripts/AgentController.cs(72,124): error CS1502: The best overloaded method match for `UnityEngine.Vector3.Vector3(float, float, float)' has some invalid arguments
展开
 我来答
就叫江南
2014-07-04 · TA获得超过779个赞
知道小有建树答主
回答量:504
采纳率:0%
帮助的人:525万
展开全部
Vector3 A =new Vector3(hit.point.x,hit.collider.gameObject.transform.position.y,hit.point.z);
pointerObj.transform.position=A;
追问
和我的有区别吗
追答

Vector3 A =new Vector3(hit.point.x,hit.collider.gameObject.transform.position.y,hit.point.z);

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式