您的位置:首頁 > 動漫 >

全球觀察:MOHO Tutorial 5.9: Basic Physics (Pro Only)

Tutorial 5.9: Basic Physics (Pro Only)


【資料圖】

Moho features a physics engine that allows objects to collide with and bounce off of ?each other.

教程 5.9:基礎(chǔ)物理(僅限專業(yè)版)

Moho 具有一個物理引擎,允許對象相互碰撞和反彈。

Physics will only work with objects that are filled.物理學(xué)僅適用于已填充的對象。

Creating the Objects

A Moho project can contain objects that are not affected by physics, as well as ?objects that are affected by physics. The deciding factor between the two types ?of objects is a group layer that holds the objects that physics are applied to. Any ?objects not contained within this group are unaffected by the physics properties.?

In the first steps in this tutorial, you’ll create a base object Group layer that holds ?three objects, on three different layers.

To create a physics simulation,?

1. Create a new project. Add a new Group layer in the Layers window. The new ?layer will be named Layer 2.

創(chuàng)建對象

Moho 項目可以包含不受物理影響的對象,以及受物理影響的對象。 兩種類型的對象之間的決定因素是一個組層,其中包含應(yīng)用物理的對象。 未包含在該組中的任何對象都不受物理屬性的影響。

在本教程的第一步中,您將創(chuàng)建一個基礎(chǔ)對象組圖層,該圖層包含三個不同圖層上的三個對象。

要創(chuàng)建物理模擬,

1. 創(chuàng)建一個新項目。 在圖層窗口中添加一個新的組圖層。 新層將命名為第 2 層。

2. Drag the existing Layer 1 into the new group layer. On this layer, use the Add ?Point tool with the Sharp Corners option checked to create a base shape that ?the physics objects will collide with.

2. 將現(xiàn)有的圖層 1 拖到新的圖層組中。 在這一層上,使用選中銳角選項的添加點工具來創(chuàng)建物理對象將與之碰撞的基本形狀。

3. With layer 1 selected, add another vector layer (which will be named Layer 2 by ?default - rename it Layer 3). It will automatically be added to the Group layer. ?Use the Draw Shape tool to draw a circle on this layer. This will be one of the ?shapes that collide with Layer 1.?

4. Add another vector layer (Layer 4) to the Group layer, and create a rectangle ?with the Draw Shape tool on this layer.

3. 選擇第 1 層,添加另一個矢量圖層(默認命名為第 2 層 - 將其重命名為第 3 層)。 它將自動添加到組圖層。 使用繪制形狀工具在該圖層上繪制一個圓圈。 這將是與第 1 層碰撞的形狀之一。

4. 將另一個矢量圖層(第 4 層)添加到組圖層,并在此圖層上使用繪制形狀工具創(chuàng)建一個矩形。

Enabling Physics?

You now have a scene with a group that contains three objects: a base object, and ?two additional objects that will bounce against it. The first thing you need to do is ?enable physics in the Group layer that holds these objects.?

Select the Group layer (Layer 2) and open the Layer Settings dialog. Click the ?Physics tab to display the following settings:

啟用物理

您現(xiàn)在有一個包含三個對象的組的場景:一個基礎(chǔ)對象和兩個將在其上反彈的附加對象。 您需要做的第一件事是在包含這些對象的 Group 層中啟用物理。

選擇組圖層(圖層 2)并打開圖層設(shè)置對話框。 單擊物理選項卡以顯示以下設(shè)置:

? Enable physics: Check this option to turn the physics simulator on.?

? Gravity direction: Use the directional slider to point to the direction from ?which gravity is originated. By default, the direction is straight down (270 ?degrees). 0/360 degrees is at the 3:00 position of the dial.?

? Gravity magnitude: Controls the strength of the gravity. Lower values make ?the gravity less forceful (objects are lighter) and higher values make the ?gravity more forceful (objects are heavier).

5. Click OK to close the Layer Settings dialog. Your group layer is now configured ?to use physics。

啟用物理:選中此選項以打開物理模擬器。

重力方向:使用方向滑塊指向重力產(chǎn)生的方向。 默認情況下,方向是直線向下(270 度)。 0/360 度位于表盤的 3:00 位置。

重力大?。嚎刂浦亓Φ膹姸?。 值越低,重力越小(物體更輕),值越高,重力越大(物體更重)。

5. 單擊確定關(guān)閉圖層設(shè)置對話框。 您的圖層組現(xiàn)在已配置為使用物理。

Creating a Collision Base?

After you enable physics in the Group layer as described in the previous section, ?your next step is to assign one of the objects as a stationary collision base for the ?others to collide against. Otherwise, the gravity in the Physics engine will cause all of ?the objects to drop off the screen.

6. Select the base layer (Layer 1) in the Group layer. This is the object that the ?other objects will collide against. Open the Layer Settings window to the Physics ?tab. You will see the following settings:?

? Enable Physics: This option should automatically be turned on if it is in a ?Group layer that has Physics enabled. If you uncheck the option, physics ?will not work on the current layer.

? Non-moving object: Check this option to make the current layer stationary. ?When this option is checked all of the other options in the Physics tab ?become disabled?

7. Click OK to return to the scene?

創(chuàng)建碰撞基礎(chǔ)

如上一節(jié)所述,在 Group 層中啟用物理后,下一步是將其中一個對象指定為固定碰撞基礎(chǔ),以供其他對象碰撞。 否則,物理引擎中的重力會導(dǎo)致所有對象從屏幕上掉下來。

6. 在 Group 圖層中選擇基礎(chǔ)圖層(圖層 1)。 這是其他對象將碰撞的對象。 打開層設(shè)置窗口到物理選項卡。 您將看到以下設(shè)置:

啟用物理:如果該選項位于啟用了物理的組層中,則應(yīng)自動打開此選項。 如果取消選中該選項,物理將不會在當(dāng)前層上工作。

非移動對象:選中此選項可使當(dāng)前圖層靜止。 選中此選項后,“物理”選項卡中的所有其他選項都將被禁用

7.點擊確定返回現(xiàn)場

Configuring Physics Objects:

After you create one or more stationary objects, you then configure the properties ?for the other objects that will bounce against them. In the case of the scene that we ?have created, these objects are the circle and the rectangle. Start with the circle ?first, and then the rectangle, and proceed as follows?

1. Select the circle layer (Layer 3) inside the Group layer. Open the Layer Settings ?window to the Physics tab. You will see the following settings:

創(chuàng)建一個或多個靜止對象后,您可以配置其他將對其反彈的對象的屬性。 在我們創(chuàng)建的場景中,這些對象是圓形和矩形。 先從圓形開始,然后是矩形,然后按以下步驟進行

1. 選擇 Group 圖層內(nèi)的圓形圖層(圖層 3)。 打開層設(shè)置窗口到物理選項卡。 您將看到以下設(shè)置:

? Enable Physics: This option should automatically be turned on as described ?in the previous section.?

? Non-moving object: Leave this option unchecked for the circle and ?rectangle layers.?

Leave the remainder of the settings at their default values for ?the circle and rectangle layers. The functions of the additional ?settings follow.?

? Start asleep: Check this option if you want an object to stay still until ?something else bumps into it. To demonstrate how this works, compare two ?versions of the project.

? Lifetime (frames): A physics object will fall, bounce around, etc. for the ?duration of its lifetime (number of frames). After that time, it will be sent ?back to its initial starting position, where it will start bouncing around ?again. A lifetime of zero means the object will never be sent back to its ?starting point. The Lifetime setting is useful for something like a hillside of ?falling boulders. Instead of creating hundreds of boulders, you can create ?a dozen or so and set the lifetime to the length of time it takes for the?boulders to fall from the top of the hill to the bottom. If the top and bottom ?of the hill are offscreen, this will look like an endless number of boulders ?falling down the hill.?

? Initial direction: Works in conjunction with the Initial Speed setting below. ?If given an initial speed of something more than zero, a physics object will ?start flying out in the designated direction at the specified speed.?

? Initial speed: Controls the speed at which physics objects move in the ?designated direction. Faster speeds allow you to create objects like bullets, ?rockets, etc.?

? Density: The default Density setting is 1. Decrease this setting to make ?objects more responsive to collisions. Increase the setting to make objects ?less responsive to collisions.?

? Friction: A contact force between two surfaces that controls how much ?they slow each other down when they touch. High friction objects (like a ?brick sliding on concrete) will generally slow down faster than low friction ?objects (blocks of ice).?

? Springiness: When two objects collide, their springiness values define how ?much they will bounce apart. A basketball bouncing on a floor would ?have a high springiness value, while a stick of butter would have a low ?springiness value.?

? Pivot on origin: This option sets an axle around the object’s origin point. ?When another object collides with an object that is set to pivot, the object ?will spin around its origin rather than topple over.?

? Motor speed: Works in conjunction with motor torque, which follows. The ?motor speed is the number of degrees per second the object will rotate ?(it can be negative to rotate backwards). Depending if the object bumps ?into obstacles or there are other influences, it may not actually rotate at ?that speed, but in a zero gravity setup with no collisions, that will be the ?speed of rotation.?

? Motor torque: Motor torque controls the strength of the motor. With low ?torque, when a motorized object bumps into other objects it may come ?to a stop, depending on the size and density of the obstacles. With a high ?torque, it will tend to push obstacles out of its way. Even with no obstacles, ?if a motorized object is unbalanced (off center of its origin), a low torque ?setting may mean that it can even lift itself up.?

2. Press Play to see what happens. The circle falls straight down and stops at the ?ground.?

3. Rewind the project to frame zero, and use the Transform Layer tool to move the ?circle so that it is just above the left pillar of the collision base, as shown in the ?following figure. Also position the circle so that the bottom center is past the ?edge of the column.

啟用物理:此選項應(yīng)如上一節(jié)所述自動打開。

非移動對象:對于圓形和矩形圖層,不要選中此選項。

將其余設(shè)置保留為圓形和矩形圖層的默認值。附加設(shè)置的功能如下。

開始入睡:如果您想讓一個物體保持靜止直到有其他東西撞到它,請選中此選項。為了演示這是如何工作的,請比較項目的兩個版本。

生命周期(幀數(shù)):物理對象會在其生命周期(幀數(shù))內(nèi)下落、反彈等。在那之后,它將被送回其初始起始位置,在那里它將再次開始彈跳。生命周期為零意味著對象永遠不會被送回其起點。 Lifetime 設(shè)置對于像落下巨石的山坡很有用。您可以創(chuàng)建十幾塊巨石,而不是創(chuàng)建數(shù)百個巨石,并將生命周期設(shè)置為巨石從山頂落到底部所需的時間長度。如果山的頂部和底部不在屏幕上,這看起來就像無數(shù)的巨石從山上掉下來。

初始方向:與下面的初始速度設(shè)置結(jié)合使用。如果給定的初始速度大于零,物理對象將開始以指定的速度沿指定方向飛出。

初始速度:控制物理對象在指定方向上移動的速度。更快的速度允許您創(chuàng)建子彈、火箭等物體。

密度:默認的“密度”設(shè)置為 1。減小此設(shè)置可使對象對碰撞更敏感。增加設(shè)置以降低對象對碰撞的響應(yīng)。

摩擦力:兩個表面之間的接觸力,控制它們在接觸時彼此減速的程度。高摩擦物體(如在混凝土上滑動的磚塊)通常比低摩擦物體(冰塊)減速得更快。

彈性:當(dāng)兩個物體發(fā)生碰撞時,它們的彈性值定義了它們彈開的程度。在地板上彈跳的籃球具有較高的彈性值,而一塊黃油的彈性值較低。

Pivot on origin:此選項設(shè)置圍繞對象原點的軸。當(dāng)另一個對象與設(shè)置為樞軸的對象發(fā)生碰撞時,該對象將圍繞其原點旋轉(zhuǎn)而不是翻倒。

電機速度:與電機扭矩一起工作,如下所示。電機速度是物體每秒旋轉(zhuǎn)的度數(shù)(向后旋轉(zhuǎn)可以是負數(shù))。根據(jù)物體是否撞到障礙物或有其他影響,它實際上可能不會以該速度旋轉(zhuǎn),但在沒有碰撞的零重力設(shè)置中,這將是旋轉(zhuǎn)速度。

電機扭矩:電機扭矩控制著電機的強度。在低扭矩的情況下,當(dāng)一個機動物體撞到其他物體時,它可能會停下來,這取決于障礙物的大小和密度。在高扭矩的情況下,它傾向于將障礙物推開。即使沒有障礙物,如果機動物體不平衡(偏離其原點的中心),低扭矩設(shè)置可能意味著它甚至可以自行升起。

2. 按播放看看會發(fā)生什么。圓圈直接落下,停在了地面上。

3.將項目倒回零幀,并使用變換圖層工具移動圓圈,使其剛好位于碰撞底座的左柱上方,如下圖所示。還要定位圓,使底部中心超過柱的邊緣。

4. Press the Play button again to observe how the circle moves. This time, it should ?collide with the rectangle, and the rectangle will respond to the collision.?

5. Experiment with additional settings to learn more about how they affect your ?objects.

4. 再次按下播放按鈕,觀察圓圈如何移動。 這一次,它應(yīng)該與矩形發(fā)生碰撞,矩形將響應(yīng)碰撞。

5. 嘗試其他設(shè)置以了解更多關(guān)于它們?nèi)绾斡绊懩膶ο蟮男畔ⅰ?/p>

Additional Comments?

You can also apply physics to bone layers. The physics are applied to the region of ?influence of the bone. See “Bone Physics (Pro Only)” on page 101 in your Moho Users Manual.

附加評論

您還可以將物理應(yīng)用到骨骼層。 物理學(xué)應(yīng)用于骨骼的影響區(qū)域。 請參閱 Moho 用戶手冊中第 101 頁的“骨骼物理(僅限專業(yè)版)”。

標(biāo)簽: GROUP 基礎(chǔ)物理 物理模擬 Moho PHYSICS

相關(guān)閱讀