1 using System;
2 using
UnityEngine;
3
4 namespace
UnityStandardAssets.Cameras
5 {
6     
public class HandHeldCam : LookatTarget
7     {
8         [SerializeField]
private float m_SwaySpeed = .5f;
9         [SerializeField]
private float m_BaseSwayAmount = .5f;
10         [SerializeField]
private float m_TrackingSwayAmount = .5f;
11         [Range(-
1, 1)] [SerializeField] private float m_TrackingBias = 0;
12
13
14         
protected override void FollowTarget(float deltaTime)
15         {
16             
base.FollowTarget(deltaTime);
17
18             
float bx = (Mathf.PerlinNoise(0, Time.time*m_SwaySpeed) - 0.5f);
19             
float by = (Mathf.PerlinNoise(0, (Time.time*m_SwaySpeed) + 100)) - 0.5f;
20
21             bx *= m_BaseSwayAmount;
22             
by *= m_BaseSwayAmount;
23
24             
float tx = (Mathf.PerlinNoise(0, Time.time*m_SwaySpeed) - 0.5f) + m_TrackingBias;
25             
float ty = ((Mathf.PerlinNoise(0, (Time.time*m_SwaySpeed) + 100)) - 0.5f) + m_TrackingBias;
26
27             tx *= -m_TrackingSwayAmount*m_FollowVelocity.x;
28             ty *= m_TrackingSwayAmount*m_FollowVelocity.y;
29
30             transform.Rotate(bx + tx,
by + ty, 0);
31         }
32     }
33 }


Tìm kết quả nhanh