关于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 展开
{
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 展开
1个回答
展开全部
Vector3 A =new Vector3(hit.point.x,hit.collider.gameObject.transform.position.y,hit.point.z);
pointerObj.transform.position=A;
pointerObj.transform.position=A;
追问
和我的有区别吗
追答
Vector3 A =new Vector3(hit.point.x,hit.collider.gameObject.transform.position.y,hit.point.z);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询