全球觀察: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 具有一個(gè)物理引擎,允許對(duì)象相互碰撞和反彈。
Physics will only work with objects that are filled.物理學(xué)僅適用于已填充的對(duì)象。
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)建對(duì)象
Moho 項(xiàng)目可以包含不受物理影響的對(duì)象,以及受物理影響的對(duì)象。 兩種類型的對(duì)象之間的決定因素是一個(gè)組層,其中包含應(yīng)用物理的對(duì)象。 未包含在該組中的任何對(duì)象都不受物理屬性的影響。
在本教程的第一步中,您將創(chuàng)建一個(gè)基礎(chǔ)對(duì)象組圖層,該圖層包含三個(gè)不同圖層上的三個(gè)對(duì)象。
要?jiǎng)?chuàng)建物理模擬,
1. 創(chuàng)建一個(gè)新項(xiàng)目。 在圖層窗口中添加一個(gè)新的組圖層。 新層將命名為第 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 拖到新的圖層組中。 在這一層上,使用選中銳角選項(xiàng)的添加點(diǎn)工具來(lái)創(chuàng)建物理對(duì)象將與之碰撞的基本形狀。
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 層,添加另一個(gè)矢量圖層(默認(rèn)命名為第 2 層 - 將其重命名為第 3 層)。 它將自動(dòng)添加到組圖層。 使用繪制形狀工具在該圖層上繪制一個(gè)圓圈。 這將是與第 1 層碰撞的形狀之一。
4. 將另一個(gè)矢量圖層(第 4 層)添加到組圖層,并在此圖層上使用繪制形狀工具創(chuàng)建一個(gè)矩形。
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)在有一個(gè)包含三個(gè)對(duì)象的組的場(chǎng)景:一個(gè)基礎(chǔ)對(duì)象和兩個(gè)將在其上反彈的附加對(duì)象。 您需要做的第一件事是在包含這些對(duì)象的 Group 層中啟用物理。
選擇組圖層(圖層 2)并打開(kāi)圖層設(shè)置對(duì)話框。 單擊物理選項(xiàng)卡以顯示以下設(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。
啟用物理:選中此選項(xiàng)以打開(kāi)物理模擬器。
重力方向:使用方向滑塊指向重力產(chǎn)生的方向。 默認(rèn)情況下,方向是直線向下(270 度)。 0/360 度位于表盤的 3:00 位置。
重力大小:控制重力的強(qiáng)度。 值越低,重力越?。ㄎ矬w更輕),值越高,重力越大(物體更重)。
5. 單擊確定關(guān)閉圖層設(shè)置對(duì)話框。 您的圖層組現(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 層中啟用物理后,下一步是將其中一個(gè)對(duì)象指定為固定碰撞基礎(chǔ),以供其他對(duì)象碰撞。 否則,物理引擎中的重力會(huì)導(dǎo)致所有對(duì)象從屏幕上掉下來(lái)。
6. 在 Group 圖層中選擇基礎(chǔ)圖層(圖層 1)。 這是其他對(duì)象將碰撞的對(duì)象。 打開(kāi)層設(shè)置窗口到物理選項(xiàng)卡。 您將看到以下設(shè)置:
啟用物理:如果該選項(xiàng)位于啟用了物理的組層中,則應(yīng)自動(dòng)打開(kāi)此選項(xiàng)。 如果取消選中該選項(xiàng),物理將不會(huì)在當(dāng)前層上工作。
非移動(dòng)對(duì)象:選中此選項(xiàng)可使當(dāng)前圖層靜止。 選中此選項(xiàng)后,“物理”選項(xiàng)卡中的所有其他選項(xiàng)都將被禁用
7.點(diǎn)擊確定返回現(xiàn)場(chǎng)
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)建一個(gè)或多個(gè)靜止對(duì)象后,您可以配置其他將對(duì)其反彈的對(duì)象的屬性。 在我們創(chuàng)建的場(chǎng)景中,這些對(duì)象是圓形和矩形。 先從圓形開(kāi)始,然后是矩形,然后按以下步驟進(jìn)行
1. 選擇 Group 圖層內(nèi)的圓形圖層(圖層 3)。 打開(kāi)層設(shè)置窗口到物理選項(xiàng)卡。 您將看到以下設(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.
啟用物理:此選項(xiàng)應(yīng)如上一節(jié)所述自動(dòng)打開(kāi)。
非移動(dòng)對(duì)象:對(duì)于圓形和矩形圖層,不要選中此選項(xiàng)。
將其余設(shè)置保留為圓形和矩形圖層的默認(rèn)值。附加設(shè)置的功能如下。
開(kāi)始入睡:如果您想讓一個(gè)物體保持靜止直到有其他東西撞到它,請(qǐng)選中此選項(xiàng)。為了演示這是如何工作的,請(qǐng)比較項(xiàng)目的兩個(gè)版本。
生命周期(幀數(shù)):物理對(duì)象會(huì)在其生命周期(幀數(shù))內(nèi)下落、反彈等。在那之后,它將被送回其初始起始位置,在那里它將再次開(kāi)始彈跳。生命周期為零意味著對(duì)象永遠(yuǎn)不會(huì)被送回其起點(diǎn)。 Lifetime 設(shè)置對(duì)于像落下巨石的山坡很有用。您可以創(chuàng)建十幾塊巨石,而不是創(chuàng)建數(shù)百個(gè)巨石,并將生命周期設(shè)置為巨石從山頂落到底部所需的時(shí)間長(zhǎng)度。如果山的頂部和底部不在屏幕上,這看起來(lái)就像無(wú)數(shù)的巨石從山上掉下來(lái)。
初始方向:與下面的初始速度設(shè)置結(jié)合使用。如果給定的初始速度大于零,物理對(duì)象將開(kāi)始以指定的速度沿指定方向飛出。
初始速度:控制物理對(duì)象在指定方向上移動(dòng)的速度。更快的速度允許您創(chuàng)建子彈、火箭等物體。
密度:默認(rèn)的“密度”設(shè)置為 1。減小此設(shè)置可使對(duì)象對(duì)碰撞更敏感。增加設(shè)置以降低對(duì)象對(duì)碰撞的響應(yīng)。
摩擦力:兩個(gè)表面之間的接觸力,控制它們?cè)诮佑|時(shí)彼此減速的程度。高摩擦物體(如在混凝土上滑動(dòng)的磚塊)通常比低摩擦物體(冰塊)減速得更快。
彈性:當(dāng)兩個(gè)物體發(fā)生碰撞時(shí),它們的彈性值定義了它們彈開(kāi)的程度。在地板上彈跳的籃球具有較高的彈性值,而一塊黃油的彈性值較低。
Pivot on origin:此選項(xiàng)設(shè)置圍繞對(duì)象原點(diǎn)的軸。當(dāng)另一個(gè)對(duì)象與設(shè)置為樞軸的對(duì)象發(fā)生碰撞時(shí),該對(duì)象將圍繞其原點(diǎn)旋轉(zhuǎn)而不是翻倒。
電機(jī)速度:與電機(jī)扭矩一起工作,如下所示。電機(jī)速度是物體每秒旋轉(zhuǎn)的度數(shù)(向后旋轉(zhuǎn)可以是負(fù)數(shù))。根據(jù)物體是否撞到障礙物或有其他影響,它實(shí)際上可能不會(huì)以該速度旋轉(zhuǎn),但在沒(méi)有碰撞的零重力設(shè)置中,這將是旋轉(zhuǎn)速度。
電機(jī)扭矩:電機(jī)扭矩控制著電機(jī)的強(qiáng)度。在低扭矩的情況下,當(dāng)一個(gè)機(jī)動(dòng)物體撞到其他物體時(shí),它可能會(huì)停下來(lái),這取決于障礙物的大小和密度。在高扭矩的情況下,它傾向于將障礙物推開(kāi)。即使沒(méi)有障礙物,如果機(jī)動(dòng)物體不平衡(偏離其原點(diǎn)的中心),低扭矩設(shè)置可能意味著它甚至可以自行升起。
2. 按播放看看會(huì)發(fā)生什么。圓圈直接落下,停在了地面上。
3.將項(xiàng)目倒回零幀,并使用變換圖層工具移動(dòng)圓圈,使其剛好位于碰撞底座的左柱上方,如下圖所示。還要定位圓,使底部中心超過(guò)柱的邊緣。
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. 再次按下播放按鈕,觀察圓圈如何移動(dòng)。 這一次,它應(yīng)該與矩形發(fā)生碰撞,矩形將響應(yīng)碰撞。
5. 嘗試其他設(shè)置以了解更多關(guān)于它們?nèi)绾斡绊懩膶?duì)象的信息。
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.
附加評(píng)論
您還可以將物理應(yīng)用到骨骼層。 物理學(xué)應(yīng)用于骨骼的影響區(qū)域。 請(qǐng)參閱 Moho 用戶手冊(cè)中第 101 頁(yè)的“骨骼物理(僅限專業(yè)版)”。