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

1. Translate

Translate (plusX, plusY, plusZ)
直接通過在當(dāng)前的x,y,z上加plusX, plusY, plusZ來移動物體
如果希望使移動不受幀率影響
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).
按百分比移動,可用于實現(xiàn)物體的速度漸減/漸增移動

4. 給rigidbody一個速度

rb.velocity =

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

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

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

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