Unity學(xué)習(xí)筆記-移動(dòng)物體的各種方式總結(jié)

1. Translate

Translate (plusX, plusY, plusZ)
直接通過(guò)在當(dāng)前的x,y,z上加plusX, plusY, plusZ來(lái)移動(dòng)物體
如果希望使移動(dòng)不受幀率影響
Translate (plusX * Time.deltatime, plusY * Time.deltatime, plusZ * Time.deltatime)

2. MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta);

MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta);
Moves a point current in a straight line towards a target point.

3. Lerp

Vector3.Lerp (Vector3 a, Vector3 b, float t);

https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html

Linearly interpolates between two vectors.

Interpolates between the vectors a and b by the interpolant t. The parameter t is clamped to the range [0, 1]. This is most commonly used to find a point some fraction of the way along a line between two endpoints (e.g. to move an object gradually between those points).
按百分比移動(dòng),可用于實(shí)現(xiàn)物體的速度漸減/漸增移動(dòng)

4. 給rigidbody一個(gè)速度

rb.velocity =

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,840評(píng)論 0 10
  • 依依以為人生這條路很長(zhǎng),所以她想找到這條叫“人生”的路,踏上它,開(kāi)始一條最為漫長(zhǎng)的旅途。 這是她媽媽告...
    久禾閱讀 626評(píng)論 0 0
  • 你喜歡長(zhǎng)發(fā)卻留著短發(fā),有顆明天就結(jié)婚的心,卻逃不過(guò)今天依舊單身的命。像我這樣長(zhǎng)期單身的姑娘,這樣的惡作劇也太可怕了...
    越小諾閱讀 231評(píng)論 0 0
  • 前面的幾片文章討論了利用故事情節(jié)或場(chǎng)景劇本來(lái)實(shí)現(xiàn)理想的用戶(hù)交互過(guò)程,之后從這些場(chǎng)景和其他來(lái)源中對(duì)需求進(jìn)行定義?,F(xiàn)在...
    Lipcui閱讀 926評(píng)論 0 0
  • 一百碗不辣的涼皮 一百支兩塊錢(qián)的小雪生 二十瓶吐白沫的綠罐飲料 二十個(gè)長(zhǎng)腿蚊子叮過(guò)的小紅包 就可以把夏天送走 En...
    親愛(ài)的園長(zhǎng)閱讀 217評(píng)論 3 3

友情鏈接更多精彩內(nèi)容