您的位置:首页 > 动漫 >

全球观察: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:基础物理(仅限专业版)

Moho 具有一个物理引擎,允许对象相互碰撞和反弹。

Physics will only work with objects that are filled.物理学仅适用于已填充的对象。

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.

创建对象

Moho 项目可以包含不受物理影响的对象,以及受物理影响的对象。 两种类型的对象之间的决定因素是一个组层,其中包含应用物理的对象。 未包含在该组中的任何对象都不受物理属性的影响。

在本教程的第一步中,您将创建一个基础对象组图层,该图层包含三个不同图层上的三个对象。

要创建物理模拟,

1. 创建一个新项目。 在图层窗口中添加一个新的组图层。 新层将命名为第 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. 将现有的图层 1 拖到新的图层组中。 在这一层上,使用选中锐角选项的添加点工具来创建物理对象将与之碰撞的基本形状。

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 层)添加到组图层,并在此图层上使用绘制形状工具创建一个矩形。

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:

启用物理

您现在有一个包含三个对象的组的场景:一个基础对象和两个将在其上反弹的附加对象。 您需要做的第一件事是在包含这些对象的 Group 层中启用物理。

选择组图层(图层 2)并打开图层设置对话框。 单击物理选项卡以显示以下设置:

ƒ 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。

启用物理:选中此选项以打开物理模拟器。

重力方向:使用方向滑块指向重力产生的方向。 默认情况下,方向是直线向下(270 度)。 0/360 度位于表盘的 3:00 位置。

重力大小:控制重力的强度。 值越低,重力越小(物体更轻),值越高,重力越大(物体更重)。

5. 单击确定关闭图层设置对话框。 您的图层组现在已配置为使用物理。

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 

创建碰撞基础

如上一节所述,在 Group 层中启用物理后,下一步是将其中一个对象指定为固定碰撞基础,以供其他对象碰撞。 否则,物理引擎中的重力会导致所有对象从屏幕上掉下来。

6. 在 Group 图层中选择基础图层(图层 1)。 这是其他对象将碰撞的对象。 打开层设置窗口到物理选项卡。 您将看到以下设置:

启用物理:如果该选项位于启用了物理的组层中,则应自动打开此选项。 如果取消选中该选项,物理将不会在当前层上工作。

非移动对象:选中此选项可使当前图层静止。 选中此选项后,“物理”选项卡中的所有其他选项都将被禁用

7.点击确定返回现场

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:

创建一个或多个静止对象后,您可以配置其他将对其反弹的对象的属性。 在我们创建的场景中,这些对象是圆形和矩形。 先从圆形开始,然后是矩形,然后按以下步骤进行

1. 选择 Group 图层内的圆形图层(图层 3)。 打开层设置窗口到物理选项卡。 您将看到以下设置:

ƒ 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.

启用物理:此选项应如上一节所述自动打开。

非移动对象:对于圆形和矩形图层,不要选中此选项。

将其余设置保留为圆形和矩形图层的默认值。附加设置的功能如下。

开始入睡:如果您想让一个物体保持静止直到有其他东西撞到它,请选中此选项。为了演示这是如何工作的,请比较项目的两个版本。

生命周期(帧数):物理对象会在其生命周期(帧数)内下落、反弹等。在那之后,它将被送回其初始起始位置,在那里它将再次开始弹跳。生命周期为零意味着对象永远不会被送回其起点。 Lifetime 设置对于像落下巨石的山坡很有用。您可以创建十几块巨石,而不是创建数百个巨石,并将生命周期设置为巨石从山顶落到底部所需的时间长度。如果山的顶部和底部不在屏幕上,这看起来就像无数的巨石从山上掉下来。

初始方向:与下面的初始速度设置结合使用。如果给定的初始速度大于零,物理对象将开始以指定的速度沿指定方向飞出。

初始速度:控制物理对象在指定方向上移动的速度。更快的速度允许您创建子弹、火箭等物体。

密度:默认的“密度”设置为 1。减小此设置可使对象对碰撞更敏感。增加设置以降低对象对碰撞的响应。

摩擦力:两个表面之间的接触力,控制它们在接触时彼此减速的程度。高摩擦物体(如在混凝土上滑动的砖块)通常比低摩擦物体(冰块)减速得更快。

弹性:当两个物体发生碰撞时,它们的弹性值定义了它们弹开的程度。在地板上弹跳的篮球具有较高的弹性值,而一块黄油的弹性值较低。

Pivot on origin:此选项设置围绕对象原点的轴。当另一个对象与设置为枢轴的对象发生碰撞时,该对象将围绕其原点旋转而不是翻倒。

电机速度:与电机扭矩一起工作,如下所示。电机速度是物体每秒旋转的度数(向后旋转可以是负数)。根据物体是否撞到障碍物或有其他影响,它实际上可能不会以该速度旋转,但在没有碰撞的零重力设置中,这将是旋转速度。

电机扭矩:电机扭矩控制着电机的强度。在低扭矩的情况下,当一个机动物体撞到其他物体时,它可能会停下来,这取决于障碍物的大小和密度。在高扭矩的情况下,它倾向于将障碍物推开。即使没有障碍物,如果机动物体不平衡(偏离其原点的中心),低扭矩设置可能意味着它甚至可以自行升起。

2. 按播放看看会发生什么。圆圈直接落下,停在了地面上。

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. 再次按下播放按钮,观察圆圈如何移动。 这一次,它应该与矩形发生碰撞,矩形将响应碰撞。

5. 尝试其他设置以了解更多关于它们如何影响您的对象的信息。

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.

附加评论

您还可以将物理应用到骨骼层。 物理学应用于骨骼的影响区域。 请参阅 Moho 用户手册中第 101 页的“骨骼物理(仅限专业版)”。

标签: GROUP 基础物理 物理模拟 Moho PHYSICS

相关阅读