资源简介
unity官方赛车demo。简单的漂移,有漂移痕迹。仅供学习!
代码片段和文件信息
using System;
using UnityEngine;
namespace UnityStandardAssets.Cameras
{
public abstract class AbstractTargetFollower : MonoBehaviour
{
public enum UpdateType // The available methods of updating are:
{
FixedUpdate // Update in FixedUpdate (for tracking rigidbodies).
LateUpdate // Update in LateUpdate. (for tracking objects that are moved in Update)
ManualUpdate // user must call to update camera
}
[SerializeField] protected Transform m_Target; // The target object to follow
[SerializeField] private bool m_AutoTargetPlayer = true; // Whether the rig should automatically target the player.
[SerializeField] private UpdateType m_UpdateType; // stores the selected update type
protected Rigidbody targetRigidbody;
protected virtual void Start()
{
// if auto targeting is used find the object tagged “Player“
// any class inheriting from this should call base.Start() to perform this action!
if (m_AutoTargetPlayer)
{
FindAndTargetPlayer();
}
if (m_Target == null) return;
targetRigidbody = m_Target.GetComponent();
}
private void FixedUpdate()
{
// we update from here if updatetype is set to Fixed or in auto mode
// if the target has a rigidbody and isn‘t kinematic.
if (m_AutoTargetPlayer && (m_Target == null || !m_Target.gameobject.activeSelf))
{
FindAndTargetPlayer();
}
if (m_UpdateType == UpdateType.FixedUpdate)
{
FollowTarget(Time.deltaTime);
}
}
private void LateUpdate()
{
// we update from here if updatetype is set to Late or in auto mode
// if the target does not have a rigidbody or - does have a rigidbody but is set to kinematic.
if (m_AutoTargetPlayer && (m_Target == null || !m_Target.gameobject.activeSelf))
{
FindAndTargetPlayer();
}
if (m_UpdateType == UpdateType.LateUpdate)
{
FollowTarget(Time.deltaTime);
}
}
public void ManualUpdate()
{
// we update from here if updatetype is set to Late or in auto mode
// if the target does not have a rigidbody or - does have a rigidbody but is set to kinematic.
if (m_AutoTargetPlayer && (m_Target == null || !m_Target.gameobject.activeSelf))
{
FindAndTargetPlayer();
}
if (m_UpdateType == UpdateType.ManualUpdate)
{
FollowTarget(Time.deltaTime);
}
}
protected abstract void FollowTarget(float deltaTime);
public void FindAndTargetPlayer()
{
// auto target
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-05-10 20:44 UnitySkidmarks-master\
文件 378 2017-05-10 20:44 UnitySkidmarks-master\.gitattributes
文件 82 2017-05-10 20:44 UnitySkidmarks-master\.gitignore
目录 0 2017-05-10 20:44 UnitySkidmarks-master\Assets\
文件 525848 2017-05-10 20:44 UnitySkidmarks-master\Assets\New Terrain.asset
文件 208 2017-05-10 20:44 UnitySkidmarks-master\Assets\New Terrain.asset.me
文件 52492 2017-05-10 20:44 UnitySkidmarks-master\Assets\Sample Scene.unity
文件 110 2017-05-10 20:44 UnitySkidmarks-master\Assets\Sample Scene.unity.me
文件 193 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets.me
目录 0 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\
文件 127 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras.me
目录 0 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\
文件 3280 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\CameraGuidelines.txt
文件 113 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\CameraGuidelines.txt.me
文件 127 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
目录 0 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 3461 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 198 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 5745 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 198 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 4827 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 198 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 1127 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 198 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 2714 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 198 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 787 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 213 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 5942 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 198 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
文件 3171 2017-05-10 20:44 UnitySkidmarks-master\Assets\Standard Assets\Cameras\sc
............此处省略106个文件信息
- 上一篇:arcgis和mapgis两个版本二调符号库
- 下一篇:Liquid Volume
相关资源
- Liquid Volume
- 2DGameplayTutorialProject.zip
- Unity官方局域网游戏源代码
- Unity展厅模型 Showroom Environment 1.1
- Unity飞行模拟 Flight Simulation Enine
- Mastering Unity 2D Game Development - Second E
- 安卓Unity 3D dll文件解密工具get_dll_fr
- Helios 1.3.1 录制全景视频 VR
- NGUI v3.12.1 2018 最新版NGUI
- unity小游戏四子连珠
- 坦克大战unity,2d
- Old SteamVR.unitypackage
- Unity NGUI 滑动列表渐变缩放,偏移,渐
- csdn_curve_upload.zip
- Unity BestHttp
- unity2d实现的贪吃蛇游戏
- Unity 4.3 2D横版射击游戏
- unity高速设施资源
- 800个Unity材质球
- SciFiArsenal1.0.unitypackage
- Magic Missiles and Lasers.unitypackage
- AR室内导航Demo
- Unity Sci-FI UI Design for UGUI1.0
- Unity官方案例精讲 2015版高清中文
- 三个AI小游戏unity-五子棋、扫雷、Wu
- unity3d小游戏
- Unity3D模型-各种石头、蘑菇、小草、树
- Unity 3D网络游戏实战(全)
- unity3d 真实世界地形插件
- Unity 5.X 2017标准教程.zip
评论
共有 条评论