開始時間:2016年7月31日21:37:37html
參考連接:http://unity3d.com/learn/tutorials/projects/space-shooter-tutorialc#
add Rigidbody Componentapp
To detect collision, the physics engine, through the rigid body, needs to know the volume of our objects.We need to know how much space these objects take up in our game to calculate the collisions. We give this information to the rigid body by using a cage that we wrap around our game objects. This cage defines the volume of that object. The cage is called a Collider.less
add CapsuleCollider Componentdom
remove itide
add MeshCollider Component, select "Convex"學習
The Mesh Collider component will not participate properly in physics
collisions and will not be visible in the scene view unless we select
「Convex」 on the Mesh Collider Component.
There are some limitations when using the Mesh Collider. Non-convex Mesh Colliders are only supported on GameObjects without a rigidbody. If you want to use a Mesh Collider on a rigidbody, it needs to be marked as Convex.this
select "Is Trigger"spa
We simply need our collision to trigger an action.3d
打卡:2016年8月1日21:25:18
Set Camera
by default in Unity 5, a Skybox is included in thescene. This skybox will influence the ambient light affecting the shipand will be used as the background image by the Main Camera.
Set Light
main light, a fill light, a rim light
We can organize our hierarchy by using empty Game Objects.
And It is important to reset the transform of this empty game object.
打卡:2016年8月2日14:08:19(昨天看的有點少)
add a quad object, rotate, remove mesh collider component.
What is a matte paint?
Glossy and flat (or matte) are typical extreme levels of glossiness of a finish. Glossypaints are shiny and reflect most light in the specular (mirror-like) direction, while onflat paints most of the light diffuses in a range of angles. The gloss level of paintcan also affect its apparent colour.
move the background down.
add Script named PlayerController.cs to Player GameObject
"camelCase" isn't PascalCase, but "PascalCase" is.
use Input.GetAxis() to 獲得運動的份量 來 設置 rb.velocity() 從而使飛船運動。
設置飛船運行的限制區域
學習 Class Boundary 的用法
Mathf - A collection of common math functions.
Mathf.Clamp(float value, float min, float max)
將value限制在 min 和 max 之間
設置 飛船的 tilt,讓飛船在左右移動的時候有適當的傾斜。
Quaternion Euler(float x, float y, float z)
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).
Creating shots by assembling artwork, physics components and custom C# code.
We are going to separate the game logic from our visual effect of the shot. This will allow us to easily make new weapons with different visual effects by reusing the parent game object with the logic and replacing the visual effect layer.
Create a Quad VFX to hold the visual effect image. Add the VFX game object as a child of Bolt.
Create a Material fx_bolt_orange for the Quad VFX. Drag the Material on to the Quad.
Look at Quad VFX game object, We Change the shader on the material fx_bolt_orange to Particles - Additive
With shader particles/additive, black has a value of 0 and will add nothing to the scene. And white has a value of 255 on all channels and will add full white to the scene. All of the other colours will be added on top of the existing background. This will give us a strong, hot laser bolt.
We can also change Shader to mobile/particle/additive.
In general the mobile shader will be more efficient with our game's resource budget, but in some cases may sacrifice either quality or control. The main control that we will lose by using this mobile shader is the ability to change the tint colour, which we don't need on our laser bolt.
with our visual effect set up, let's move on to setting up our logic.也就是說配置 Bolt 對象。
Writing the code and setting up the scene to shoot shots.
What we need to do is instantiate a copy of clone of this Shot prefab when we hit a button or click a mouse during our gameplay.
打卡:2016年8月3日20:29:59
Creating a bounding box to destroy any object that leaves the game area.
We are going to create a box around our game and we will destroy these shots as they leave the box.(因此咱們使用 OnTriggerExit(Collider))
注:The number of units from the top of the screen to the bottom is always twice the value of our camera's orthographic size.
Create an asteroid hazard to challenge the player.
注:We will have a parent game object for the logic and the artwork will be a child.
讓小行星隨機旋轉用到 Random.insideUnitSphere
Returns a random point inside a sphere with radius 1 (Read Only).
Set Angular Drag value to 0. 避免小行星中止自轉。
Write trigger collider code for our 2 colliders to have any effect.
咱們發現小行星因爲和Boundary接觸而消失,爲了不這一效果,tag our boundary.
// DestroyByContact.cs using UnityEngine; using System.Collections; public class DestroyByContact : MonoBehaviour { void OnTriggerEnter(Collider other) { // Debug.Log(other.name); if(other.tag == "Boundary") // 當 other 的 tag 是 Boundary 的時候,跳過 { return; } Destroy(other.gameObject); // Destroy the laser bolt when it hits the asteroid. Destroy(gameObject); // Destroy the asteroid itself. } }
Add explosions to the scene when hazards or the player is destroyed.