Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Creating 3D Game Art for the iPhone with Unity Part 8 potx
MIỄN PHÍ
Số trang
28
Kích thước
3.0 MB
Định dạng
PDF
Lượt xem
776

Creating 3D Game Art for the iPhone with Unity Part 8 potx

Nội dung xem thử

Mô tả chi tiết

set as Rigid Bodies. In order to accomplish this, we’ll need to set

up some logic for the simulation, which can be done through the

Logic Editor.

Setting Up the Logic

We’ll first set up the logic for the sphere. First, we’ll add a Game

Property, which I called “col,” by clicking the Add Game Property

button as shown in Fig. 7.36. This property will be used later to

only trigger the simulation for the target pieces when the sphere

strikes them.

For the UV Sphere, we’ll need to create two layers of logic. The

first layer will suspend the dynamics so when we start the simula￾tion, the gravity won’t automatically affect the

Rigid Body objects. The second layer, re-enable the

dynamics, but only after we hit the space bar. In

Fig. 7.37, you can see both layers highlighted. The

first layer consists of an “Always” Sensor, a “And”

Controller, and one “Edit Object” Actuator set to

Suspend Dynamics. As you can see from Fig. 7.37,

these items are piped together.

The second layer of logic consists of a “Keyboard”

Sensor set to Spacebar, an “And” Controller, and

two Actuators, an “Edit Object” set to Restore

Dynamics and a “Motion” Actuator set to simple

motion with a value of −2.0 in the Y-axis. Again

in Fig. 7.37, you can see how this logic is piped

together. The second layer of logic is stated that

when the Spacebar is pressed, dynamics will be

restored and a motion of −2.0 will be applied to

the UV Sphere in the Y-axis, which will push the

ball into the target.

Next, we’ll need to set up the logic for each piece

of the target. It’s a very similar setup in that there

are two layers of logic. The first layer will suspend

the dynamics and the second layer will re-enable

the dynamics, but instead of using a “Keyboard”

Sensor, we’ll use a “Collision” Sensor. The colli￾sion event will be the UV Sphere colliding with

the ball, and we’ll use the “col” Game Property set on the UV Sphere to tell

our logic that we only want to test for a collision with the game object that

contains the “col” Game Property, which in our case is the UV Sphere. When

this collision happens, the second layer of logic will re-enable the dynamics,

just as we discussed before. In Fig. 7.38, you can see the completed logic for

the target pieces.

178

Creating 3D Game Art for the iPhone with Unity

Fig 7.35 The Bullet Physics Engine

Defaults to 9.8.

Fig 7.34 The Ground Is Set to Static.

At this point, the entire simulation is set. If I were to hit the P key to start

the game followed by the Spacebar, the sphere will hit the target and

explode it into pieces as shown in Fig. 7.39. Next, I just need to bake the

simulation into keyframes so that the animation can be imported into

Unity iOS.

Baking the Simulation

To bake the Rigid Body simulation, you need to go to the Game menu at the

top of the Blender UI and enable Record Animation as shown in Fig. 7.40.

With this option activated, you then need to run the simulation by press￾ing the P key. Remember, because we set up a Keyboard Sensor, we’ll have

179

Animation Using Blender

Fig 7.36 A Game Property Called

“col” Is Added to the UV Sphere.

Tải ngay đi em, còn do dự, trời tối mất!