第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

基于坐標放置對象,而不是Unity中的中心坐標

基于坐標放置對象,而不是Unity中的中心坐標

C#
烙印99 2022-12-24 09:42:06
我正在根據(jù)屏幕動態(tài)創(chuàng)建網(wǎng)格對象。因此包含網(wǎng)格對象的對象總是大小相同,但網(wǎng)格對象具有不同的形狀和大小。我想讓你看到我的照片并理解它。事實上,藍色區(qū)域是透明的。我目前正在使用移動相機在地板上拍攝 Ray,我想將物體放置在 Ray 擊中的位置。但這似乎需要大量的計算。我認為我們應該首先使用對象中心坐標以外的其他坐標。而且我認為我們應該將物體放置在碰撞點上方一點點。網(wǎng)格對象的一半大小,所以我嘗試了這個,但我失敗了。我該如何解決這個問題?下面是我的源代碼。Vector3 hitPositon = hit.Pose.position;Vector3 meshObjectCenter = ObjectPrefab.GetComponent<Renderer>().bounds.center;Vector3 meshObjectSize = ObjectPrefab.GetComponent<Renderer>().bounds.size;Vector3 CenterPointRevision = meshObjectCenter - hitPositon;Vector3 YAxisRevision = new Vector3(0, meshObjectSize.y / 2, 0);           Vector3 NewPoint = ARObjectPrefab.transform.position - CenterPointRevision + YAxisRevision;           ObjectPrefab.transform.position = NewPoint;object就是這種格式,上圖看起來是成功但失敗的情況。
查看完整描述

1 回答

?
達令說

TA貢獻1821條經(jīng)驗 獲得超6個贊

該位置只是命中位置減去中心偏移量加上 y 軸偏移量:


Vector3 hitPositon = hit.Pose.position;

Vector3 meshObjectCenter = ObjectPrefab.GetComponent<Renderer>().bounds.center;

Vector3 meshObjectSize = ObjectPrefab.GetComponent<Renderer>().bounds.size;

Vector3 YAxisRevision = new Vector3(0, meshObjectSize.y / 2, 0);

ObjectPrefab.transform.position = hitPositon - meshObjectCenter + YAxisRevision;


查看完整回答
反對 回復 2022-12-24
  • 1 回答
  • 0 關注
  • 93 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號