unity脚本里怎么用脚本找到相机

unity切换相机脚本_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
unity切换相机脚本
上传于|0|0|暂无简介
你可能喜欢摄像机跟随脚本 | Unity3D教程手册
当前位置 :
>> 摄像机跟随脚本
摄像机跟随脚本
distanceAway:摄像机和目标点的水平面距离。
distanceUp:摄像机和目标的高度差。
smooth:摄像机移动到目标点的平滑度,也可以理解为速度。
transform.LookAt(); :使摄像机始终朝向目标点。
脚本如下:
&&&01using UnityEngine;
02using System.Collections;
03&04public class ThirdPersonCamera : MonoBehaviour
public float distanceAway;
// distance from the back of the craft
public float distanceUp;
// distance above the craft
public float smooth;
// how smooth the camera movement is
private GameObject hovercraft;
// to store the hovercraft
private Vector3 targetPosition;
// the position the camera is trying to be in
Transform follow;
void Start(){
follow = GameObject.FindWithTag (&Player&).transform;
void LateUpdate ()
// setting the target position to be the correct offset from the hovercraft
targetPosition = follow.position + Vector3.up * distanceUp + follow.forward * distanceAway;
// making a smooth transition between it's current position and the position it wants to be in
transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smooth);
// make sure the camera is looking the right way!
transform.LookAt(follow);
【上一篇】
【下一篇】
您可能还会对这些文章感兴趣! 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
unity3d游戏开发之相机切换
下载积分:3000
内容提示:unity3d游戏开发之相机切换
文档格式:DOC|
浏览次数:197|
上传日期: 02:42:30|
文档星级:
该用户还上传了这些文档
unity3d游戏开发之相机切换
官方公共微信

我要回帖

更多关于 unity3d脚本怎么用 的文章

 

随机推荐