[Unity]常用技巧收集
Unity 鏡頭拉近效果(帶緩衝)
var target : Transform;
var distance : float = 3.0;
var height : float = 1.0;
var damping : float = 5.0;
var smoothRotation : boolean = true;
var rotationDamping : float = 10.0;
var targetLookAtOffset : Vector3; // allows offsetting of camera lookAt, very useful for low bumper heights
var bumperDistanceCheck : float = 2.5; // length of bumper ray
var bumperCameraHeight : float = 1.0; // adjust camera height while bumping
var bumperRayOffset : Vector3; // allows offset of the bumper ray from target origin
function FixedUpdate() {
var wantedPosition = target.TransformPoint(0, height, -distance);
// check to see if there is anything behind the target
var hit : RaycastHit;
var back = target.transform.TransformDirection(-1 * Vector3.forward);
// cast the bumper ray out from rear and check to see if there is anything behind
if (Physics.Raycast(target.TransformPoint(bumperRayOffset), back, hit, bumperDistanceCheck)) {
// clamp wanted position to hit position
wantedPosition.x = hit.point.x;
wantedPosition.z = hit.point.z;
wantedPosition.y = Mathf.Lerp(hit.point.y + bumperCameraHeight, wantedPosition.y, Time.deltaTime * damping);
}
transform.position = Vector3.Lerp(transform.position, wantedPosition, Time.deltaTime * damping);
var lookPosition : Vector3 = target.TransformPoint(targetLookAtOffset);
if (smoothRotation) {
var wantedRotation : Quaternion = Quaternion.LookRotation(lookPosition – transform.position, target.up);
transform.rotation = Quaternion.Slerp(transform.rotation, wantedRotation, Time.deltaTime * rotationDamping);
} else {
transform.rotation = Quaternion.LookRotation(lookPosition – transform.position, target.up);
}
}
Untiy 動畫加速
for (var state : AnimationState in animation)
{
state.speed = 0.5;
}
更多unity2018的功能介紹請到paws3d學習中心查詢。
相關文章
- js技巧收集JS
- unity 常用APIUnityAPI
- Unity常用宏Unity
- Javascript常用收集JavaScript
- 網頁技巧收集網頁
- kali常用的資訊收集
- 收集Chrome控制檯使用技巧點Chrome
- T-SQL技巧收集——拆分字串SQL字串
- win10個人收集小技巧Win10
- 常用的Unity輸入方法Unity
- JS 常用技巧JS
- CSS 常用技巧CSS
- Xcode 常用路徑收集XCode
- 電腦常用知識收集
- Linux常用資訊收集命令Linux
- 【Unity3D】常用快捷鍵Unity3D
- faker 資料填充常用指令收集
- redis常用demo收集(一)——總起Redis
- linux常用易忘命令收集Linux
- Oracle 常用 Dump 命令收集(轉帖)Oracle
- 【Idea】常用技巧Idea
- [Idea] 常用技巧Idea
- 【CSS】CSS常用技巧CSS
- css常用技巧梳理CSS
- 常用的JS技巧JS
- javascript常用技巧(轉)JavaScript
- 50個工作中最常用excel技巧 excel常用技巧大全Excel
- linux常用基礎命令操作收集Linux
- 轉:維護常用SQL語句收集!SQL
- JS常用簡寫技巧JS
- JS 常用簡寫技巧JS
- 常用的CSS小技巧CSS
- Maven 常用技巧總結Maven
- iView常用元件清空技巧View元件
- 【個人總結】常用技巧
- JavaScript 常用55個技巧JavaScript
- 前端常用CSS小技巧前端CSS
- Asp.net常用技巧ASP.NET