如何在unity3d开发2d游戏中控制unity摄像机控制脚本移动以及主角移动

匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。[转载]unity3d&摄像机移动
Tranform&&t大写吧?目标:实现摄像机的左、右、前、后移动
  1.新建一个空白场景(【File】 -& 【New
Scene】),在"层级【Hierarchy】”视图中单击相机,看到场景中出现一个摄像机小图标,当然你也可以移动调整摄像机
  2.创建游戏对象(【GameObject】 -& 【Create Other】
-& 【Cube】):
创建一个Cube,缩放x,y,z为”5,0.1,5”,它现在看起来应该是一个大平板.你也可以在层次视图【Hierarchy】中重命名游戏对象
  - 创建第二个Cube,将它放置在这个大平板的中心位置.如果在货源E家游戏视图(Game
View)看不到它们,那么改变主相机位置使它们可见.
  - 创建一个点光源,并且放在大平板之上,使它们更清晰.
  -保存当前场景
  3.创建脚本(Assets -& Create -&
JavaScript)
这时在【Project】多一个脚本,重命名脚本ControlCamera。这时在【Inspector】视图中看到Update()函数,Update()函数中的代码都将在每一帧(frame)执行一次。
  - 双击编辑脚本,会打开默认的编辑器,写上以下代码(不明白的地方可以查看API文档)
  var speed = 20.0;
  function Update ()
  if(Input.GetKey(KeyCode.A))
  transform.Rotate(Vector3.up);
  else if(Input.GetKey(KeyCode.D))
  transform.Rotate(Vector3.down);
  else if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S))
  var x = Input.GetAxis("Horizontal") * Time.deltaTime *
  var y = Input.GetAxis("Vertical") * Time.deltaTime *
  transform.Translate(x, 0, y);
  //transform.Rotate(Vector3.left);
  else if(Input.GetKey(KeyCode.S))
  //transform.Rotate(Vector3.right);
  4.连接脚本
  怎么让Unity的游戏对象具有这个脚本行为呢?我们要做的是赋予这个脚本给游戏对象来体现脚本的行为.
  【层次】视图中选中相机后,选择菜单【Components】-& 【Scripts】
ControlCamera,将这个脚本赋予相机,你在检视面板中看到主相机有ControlCamera这个组件
  5.预览你就可以用A D W S 来控制摄像机左 右 前 后移动了。
  注意:1)、如果看不到摄像机图标或其它游戏对象(只有选中时有三向箭头),可以在”Inspector“视图设置一下
【layer】为TransparentFX
  2)、如果摄像机图标不在视口,可以双击层级面板的摄像机,或单击层级面板的摄像机后,鼠标移到场景中按"F“键可以把摄像机切换视口;
Tags: 摄像机
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。Unity3D研究院之处理摄像机跟随避免相机穿墙拉近或透明的方法(四十四) ... - Unity3D - 安卓巴士 - 安卓开发 - Android开发 - 安卓 - 移动互联网门户 - Powered by Discuz!
ul').hide()" onmouseenter="jQuery('.sitegroup>ul').show()">
立即充值>
Unity3D研究院之处理摄像机跟随避免相机穿墙拉近或透明的方法(四十四) ...
查看: 336650|
摘要: 当摄像机处于跟随主角状态时,那么主角移动后很有可能摄像机被别的模型挡住。这样用户体验就非常不好,一般3D游戏在处理视角的时候有两种方法,第一种是让被挡住的模型变成透明,第二种是拉近摄像机。前者时候固定视 ...
当摄像机处于跟随主角状态时,那么主角移动后很有可能摄像机被别的模型挡住。这样用户体验就非常不好,一般3D游戏在处理视角的时候有两种方法,第一种是让被挡住的模型变成透明,第二种是拉近摄像机。前者时候固定视角游戏使用,后者适合变化视角游戏使用。两个我们都学一学蛤蛤。& & & & & 如下图所示,MOMO写了一个简单的例子,通过鼠标或触摸来牵引主角向不同的角度移动,旁边有一面墙当主角被这面墙挡住,此时摄像机将拉近。 && &&&首先,为了方面鼠标与移动平台上的触摸同时相应我写了一个通用的方法。包括 开始触摸 &触摸中 结束触摸 ,电脑手机都可以用这个方法相应到。JFConst.cs[代码]:using UnityE
using System.C
public class JFConst
public static
bool TouchBegin()
if(Input.GetMouseButtonDown(0))
if(Input.touchCount & 0 && Input.GetTouch(0).phase == TouchPhase.Began)
public static bool TouchEnd()
if(Input.GetMouseButtonUp(0))
if(Input.touchCount & 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
public static bool TouchIng()
if(Input.GetMouseButton(0))
}else if(Input.touchCount & 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
}以前写过一篇文章关于移动主角的,如果对移动主角还有不懂的请看这篇&& 。 这里我就不解释移动主角这部分的代码了。 下面是角色控制器ThirdPersonController.cs 绑定在主角身上。下面代码中需要详细看的就是161行到174行 ,这部分就是根据触摸屏幕的2D坐标计算主角在3D世界中移动的坐标。[代码]:using UnityE
using System.C
[RequireComponent(typeof(CharacterController))]
public class ThirdPersonController : MonoBehaviour {
public AnimationClip idleA
public AnimationClip walkA
public AnimationClip runA
public AnimationClip jumpPoseA
public float walkMaxAnimationSpeed
public float trotMaxAnimationSpeed
public float runMaxAnimationSpeed
public float jumpAnimationSpeed
public float landAnimationSpeed
private Animation _
enum CharacterState
Walking = 1,
Trotting = 2,
Running = 3,
Jumping = 4,
private CharacterState _characterS
// The speed when walking
public float walkSpeed = 2.0f;
// after trotAfterSeconds of walking we trot with trotSpeed
public float trotSpeed = 4.0f;
// when pressing "Fire3" button (cmd) we start running
public float runSpeed = 6.0f;
public float inAirControlAcceleration = 3.0f;
// How high do we jump when pressing jump and letting go immediately
public float jumpHeight = 0.5f;
// The gravity for the character
public float gravity = 20.0f;
// The gravity in controlled descent mode
public float speedSmoothing = 10.0f;
public float rotateSpeed = 500.0f;
public float trotAfterSeconds = 3.0f;
public bool canJump =
private float jumpRepeatTime = 0.05f;
private float jumpTimeout = 0.15f;
private float groundedTimeout = 0.25f;
// The camera doesnt start following the target immediately but waits for a split second to avoid too much waving around.
private float lockCameraTimer = 0.0f;
// The current move direction in x-z
private Vector3 moveDirection = Vector3.
// The current vertical speed
private float verticalSpeed = 0.0f;
// The current x-z move speed
private float moveSpeed = 0.0f;
// The last collision flags returned from controller.Move
private CollisionFlags collisionF
// Are we jumping? (Initiated with jump button and not grounded yet)
private bool jumping =
private bool jumpingReachedApex =
// Are we moving backwards (This locks the camera to not do a 180 degree spin)
private bool movingBack =
// Is the user pressing any keys?
private bool isMoving =
// When did the user start walking (Used for going into trot after a while)
private float walkTimeStart = 0.0f;
// Last time the jump button was clicked down
private float lastJumpButtonTime = -10.0f;
// Last time we performed a jump
private float lastJumpTime = -1.0f;
// the height we jumped from (Used to determine for how long to apply extra jump power after jumping.)
private float lastJumpStartHeight = 0.0f;
private Vector3 inAirVelocity = Vector3.
private float lastGroundedTime = 0.0f;
private bool isControllable =
void Awake ()
moveDirection = transform.TransformDirection(Vector3.forward);
_animation = GetComponent&Animation&();
if(!_animation)
Debug.Log("The character you would like to control doesn't have animations. Moving her might look weird.");
public var idleAnimation : AnimationC
public var walkAnimation : AnimationC
public var runAnimation : AnimationC
public var jumpPoseAnimation : AnimationC
if(!idleAnimation) {
_animation =
Debug.Log("No idle animation found. Turning off animations.");
if(!walkAnimation) {
_animation =
Debug.Log("No walk animation found. Turning off animations.");
if(!runAnimation) {
_animation =
Debug.Log("No run animation found. Turning off animations.");
if(!jumpPoseAnimation && canJump) {
_animation =
Debug.Log("No jump animation found and the character has canJump enabled. Turning off animations.");
void UpdateSmoothedMovementDirection ()
Transform cameraTransform = Camera.main.
bool grounded = IsGrounded();
// Forward vector relative to the camera along the x-z plane
Vector3 forward = cameraTransform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.
// Right vector relative to the camera
// Always orthogonal to the forward vector
Vector3 right = new Vector3(forward.z, 0, -forward.x);
float v = Input.GetAxisRaw("Vertical");
float h = Input.GetAxisRaw("Horizontal");
// Are we moving backwards or looking backwards
if (v & -0.2f)
movingBack =
movingBack =
bool wasMoving = isM
isMoving = Mathf.Abs (h) & 0.1f || Mathf.Abs (v) & 0.1f;
// Target direction relative to the camera
Vector3 targetDirection = h * right + v *
if(JFConst.TouchIng())
Vector3 vpos3 = Camera.main.WorldToScreenPoint(transform.position);
Vector2 vpos2 = new Vector2 (vpos3.x,vpos3.y);
Vector2 input = new Vector2 (Input.mousePosition.x,Input.mousePosition.y);
if(Vector2.Distance(vpos2,input) & 10.0f)
Vector2 normalied =
((vpos2 - input)).
targetDirection = new Vector3(normalied.x,0.0f,normalied.y) ;
float y = Camera.main.transform.rotation.eulerAngles.y;
targetDirection = Quaternion.Euler(0f,y - 180,0f) * targetD
// Grounded controls
if (grounded)
// Lock camera for short period when transitioning moving & standing still
lockCameraTimer += Time.deltaT
if (isMoving != wasMoving)
lockCameraTimer = 0.0f;
// We store speed and direction seperately,
// so that when the character stands still we still have a valid forward direction
// moveDirection is always normalized, and we only update it if there is user input.
if (targetDirection != Vector3.zero)
// If we are really slow, just snap to the target direction
if (moveSpeed & walkSpeed * 0.9f && grounded)
moveDirection = targetDirection.
// Otherwise smoothly turn towards it
moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000);
moveDirection = moveDirection.
// Smooth the speed based on the current target direction
float curSmooth = speedSmoothing * Time.deltaT
// Choose target speed
//* We want to support analog input but make sure you cant walk faster diagonally than just forward or sideways
float targetSpeed = Mathf.Min(targetDirection.magnitude, 1.0f);
_characterState = CharacterState.I
// Pick speed modifier
if (Input.GetKey (KeyCode.LeftShift) | Input.GetKey (KeyCode.RightShift))
targetSpeed *= runS
_characterState = CharacterState.R
else if (Time.time - trotAfterSeconds & walkTimeStart)
targetSpeed *= trotS
_characterState = CharacterState.T
targetSpeed *= walkS
_characterState = CharacterState.W
moveSpeed = Mathf.Lerp(moveSpeed, targetSpeed, curSmooth);
// Reset walk time start when we slow down
if (moveSpeed & walkSpeed * 0.3f)
walkTimeStart = Time.
// In air controls
// Lock camera while in air
if (jumping)
lockCameraTimer = 0.0f;
if (isMoving)
inAirVelocity += targetDirection.normalized * Time.deltaTime * inAirControlA
void ApplyJumping ()
// Prevent jumping too fast after each other
if (lastJumpTime + jumpRepeatTime & Time.time)
if (IsGrounded()) {
// - Only when pressing the button down
// - With a timeout so you can press the button slightly before landing
if (canJump && Time.time & lastJumpButtonTime + jumpTimeout) {
verticalSpeed = CalculateJumpVerticalSpeed (jumpHeight);
SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
void ApplyGravity ()
if (isControllable) // don't move player at all if not controllable.
// Apply gravity
bool jumpButton = Input.GetButton("Jump");
// When we reach the apex of the jump we send out a message
if (jumping && !jumpingReachedApex && verticalSpeed &= 0.0f)
jumpingReachedApex =
SendMessage("DidJumpReachApex", SendMessageOptions.DontRequireReceiver);
if (IsGrounded ())
verticalSpeed = 0.0f;
verticalSpeed -= gravity * Time.deltaT
float CalculateJumpVerticalSpeed (float targetJumpHeight)
// From the jump height and gravity we deduce the upwards speed
// for the character to reach at the apex.
return Mathf.Sqrt(2 * targetJumpHeight * gravity);
DidJump ()
jumpingReachedApex =
lastJumpTime = Time.
lastJumpStartHeight = transform.position.y;
lastJumpButtonTime = -10;
_characterState = CharacterState.J
Update() {
if (!isControllable)
// kill all inputs if not controllable.
Input.ResetInputAxes();
if (Input.GetButtonDown ("Jump"))
lastJumpButtonTime = Time.
UpdateSmoothedMovementDirection();
// Apply gravity
// - extra power jump modifies gravity
// - controlledDescent mode modifies gravity
ApplyGravity ();
// Apply jumping logic
ApplyJumping ();
// Calculate actual motion
Vector3 movement = moveDirection * moveSpeed + new Vector3 (0, verticalSpeed, 0) + inAirV
movement *= Time.deltaT
// Move the controller
CharacterController controller = GetComponent&CharacterController&();
collisionFlags = controller.Move(movement);
// ANIMATION sector
if(_animation) {
if(_characterState == CharacterState.Jumping)
if(!jumpingReachedApex) {
_animation[jumpPoseAnimation.name].speed = jumpAnimationS
_animation[jumpPoseAnimation.name].wrapMode = WrapMode.ClampF
_animation.CrossFade(jumpPoseAnimation.name);
_animation[jumpPoseAnimation.name].speed = -landAnimationS
_animation[jumpPoseAnimation.name].wrapMode = WrapMode.ClampF
_animation.CrossFade(jumpPoseAnimation.name);
if(controller.velocity.sqrMagnitude & 0.1f) {
_animation.CrossFade(idleAnimation.name);
if(_characterState == CharacterState.Running) {
_animation[runAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0f, runMaxAnimationSpeed);
_animation.CrossFade(runAnimation.name);
else if(_characterState == CharacterState.Trotting) {
_animation[walkAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0f, trotMaxAnimationSpeed);
_animation.CrossFade(walkAnimation.name);
else if(_characterState == CharacterState.Walking) {
_animation[walkAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0f, walkMaxAnimationSpeed);
_animation.CrossFade(walkAnimation.name);
// ANIMATION sector
// Set rotation to the move direction
if (IsGrounded())
transform.rotation = Quaternion.LookRotation(moveDirection);
Vector3 xzMove =
xzMove.y = 0;
if (xzMove.sqrMagnitude & 0.001f)
transform.rotation = Quaternion.LookRotation(xzMove);
// We are in jump mode but just became grounded
if (IsGrounded())
lastGroundedTime = Time.
inAirVelocity = Vector3.
if (jumping)
SendMessage("DidLand", SendMessageOptions.DontRequireReceiver);
OnControllerColliderHit (ControllerColliderHit hit )
// Debug.DrawRay(hit.point, hit.normal);
if (hit.moveDirection.y & 0.01f)
float GetSpeed () {
return moveS
public bool IsJumping () {
bool IsGrounded () {
return (collisionFlags & CollisionFlags.CollidedBelow) != 0;
Vector3 GetDirection () {
return moveD
public bool IsMovingBackwards () {
return movingB
public float GetLockCameraTimer ()
return lockCameraT
bool IsMoving ()
return Mathf.Abs(Input.GetAxisRaw("Vertical")) + Mathf.Abs(Input.GetAxisRaw("Horizontal")) & 0.5f;
bool HasJumpReachedApex ()
return jumpingReachedA
bool IsGroundedWithTimeout ()
return lastGroundedTime + groundedTimeout & Time.
void Reset ()
gameObject.tag = "Player";
}如此我们就可以通过鼠标与触摸牵引控制主角移动了,别急这紧紧是开始,下面是本章的要点。这里我们分析一下摄像机到底什么时候该拉近,什么时候该不拉近。 我的作法是这样的,当角色移动的时候我会从主角身上向摄像机方向发射一条射线,如果射线碰撞到的第一个对象是“摄像机” 那么就标示主角和摄像机之间没有别的模型挡住,此时摄像机就不应该拉近。如果射线碰撞到的第一个对象不是摄像机,那么就标示主角和摄像机之间有别的模型所挡住,此时取得射线与别的模型碰撞的3D坐标接着将“摄像机”的坐标移动到这个坐标上即可。如下图所示,(红色表示由主角发射到摄像机的射线)主角身后的射线没有被别的模型挡住,射线机不会拉近。&&如下图所示,MOMO改变了一下主角的位置,此时主角身后的射向已经被墙挡住,这时把摄像机的坐标移动到被墙挡住点的坐标,这样摄像机就拉近了。&原理大概就是这样,接着我们学习一下这段代码该如何来写。MyCamera.cs 挂在射线机上[代码]:using UnityE
using System.C
public class MyCamera : MonoBehaviour
//摄像机朝向的目标模型
//摄像机与模型保持的距离
public float distance = 10.0f;
//射线机与模型保持的高度
public float height = 5.0f;
//高度阻尼
public float heightDamping = 2.0f;
//旋转阻尼
public float rotationDamping = 3.0f;
//主角对象
private GameO
void Start()
//得到主角对象
controller = GameObject.FindGameObjectWithTag("Player");
void Update()
void LateUpdate ()
// Early out if we don't have a target
if (!target)
//当鼠标或者手指在触摸中时
if(JFConst.TouchIng())
bool follow =
//计算相机与主角Y轴旋转角度的差。
float abs = Mathf.Abs(transform.rotation.eulerAngles.y - controller.transform.rotation.eulerAngles.y);
//abs等于180的时候标示摄像机完全面对这主角, 》130 《 230 表示让面对的角度左右偏移50度
//这样做是不希望摄像机跟随主角,具体效果大家把代码下载下来看看,这样的摄像机效果很好。
if(abs & 130 && abs & 230)
float wantedRotationAngle = target.eulerAngles.y;
float wantedHeight = target.position.y +
float currentRotationAngle = transform.eulerAngles.y;
float currentHeight = transform.position.y;
//主角面朝射线机 和背对射线机 计算正确的位置
if(follow)
currentRotationAngle = Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime);
currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
Quaternion currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);
Vector3 positon = target.
positon -= currentRotation * Vector3.forward *
positon = new Vector3(positon.x,currentHeight,positon.z);
transform.position = Vector3.Lerp(transform.position,positon,Time.time);
Vector3 positon = target.
Quaternion cr = Quaternion.Euler (0, currentRotationAngle, 0);
positon += cr * Vector3.back *
positon = new Vector3(positon.x,target.position.y + height,positon.z);
transform.position = Vector3.Lerp(transform.position,positon,Time.time);
//这里是计算射线的方向,从主角发射方向是射线机方向
Vector3 aim = target.
//得到方向
Vector3 ve = (target.position - transform.position).
float an = transform.eulerAngles.y;
aim -= an *
//在场景视图中可以看到这条射线
Debug.DrawLine(target.position,aim,Color.red);
//主角朝着这个方向发射射线
if(Physics.Linecast(target.position,aim,out hit))
string name =
hit.collider.gameObject.
if(name != "MainCamera" && name !="terrain")
//当碰撞的不是摄像机也不是地形 那么直接移动摄像机的坐标
transform.position = hit.
// 让射线机永远看着主角
transform.LookAt (target);
}牛头人被墙挡住了,摄像机直接拉近了,小牛头人是不是很帅气?哈哈哈!!&&最后雨松MOMO把源码放出来,希望大家学习愉快,哇咔咔。。。下载地址:&补充 :摄像机遮挡物体透明。遮挡透明最简单的办法就是修改材质的透明度,前提需要把材质设置成支持透明通道的 shader Transparent 。 如下图所示,摄像机挡住的那面墙已经成透明状态了。&&看看代码是如何写的,把上述代码MyCamera.cs 简单的改一下就可以。 主要是92行到101行。代码核心就是通过射线得到碰撞模型的材质,然后修改材质的透明度。color.a就是透明度 1是完全不透明,0是完全透明。注意一定是支持透明通道的模型才可以。lastobj是记录上次透明的对象,用于模型透明还原使用。[代码]:if(Physics.Linecast(target.position,aim,out hit))
GameObject obj = hit.collider.gameO
string name =
if(name != "MainCamera" && name !="terrain")
Color color = obj.renderer.material.
color.a = 0.5f;
obj.renderer.material.SetColor("_Color", color);
if(lastobj != null)
Color color = lastobj.renderer.material.
color.a = 1f;
lastobj.renderer.material.SetColor("_Color", color);
}最后,假设你的模型做的非常大,贴图材质也非常的多,你像透明其中一小部分那么上述方法就不合适了,除非把他们都拆出来。我觉得也可以自己写shader实现。我们的项目采用了摄像机拉近的方式。欢迎讨论!!!&回答楼下问题:上帝视角代码,看到楼下有朋友问我,那么我就贴出来,其实很简单。下面代码挂在摄像机上, target就是角色对象,distance 是摄像机与角色的距离 height是摄像机与角色的高度。在编辑器中手动调节即可。[代码]:using UnityE
using System.C
public class ICamera : MonoBehaviour {
// The distance in the x-z plane to the target
public float distance = 10.0f;
// the height we want the camera to be above the target
public float height = 5.0f;
void LateUpdate () {
// Early out if we don't have a target
if (!target)
// Set the position of the camera on the x-z plane to:
// distance meters behind the target
transform.position = target.
transform.position -=
Vector3.forward *
transform.position = new Vector3(transform.position.x,transform.position.y + height,transform.position.z);
// Always look at the target
transform.LookAt (target);
}回答问题 :摄像机抖动如何修改今天微薄上有个朋友问我这样的问题,我在这里解答一下。来福12345:我又厚颜无耻的来了,您的《Unity3D的研究院之处理摄像机跟随避免相机穿墙拉近或透明的方法(四十四)》对于不规则的物体该怎么弄,我是直接在unity上弄了几个山脉,由于地面凹凸不平,沿着山走的时候发现摄像机会一直透视,而且抖动的很厉害,请问该怎么解决啊&1.从设计上避免射线遇到一些复杂的面,如下图所示,红颜色是主角身后的射线,当主角身后的射线碰撞到这样的面,如果此时移动速快快一些摄像机肯定会抖动。 这里最好直接删除Mesh Collider 换成BoxCollider 效率还可以得到提升。产经设计这块我觉得可以参考一下魔兽世界,我在项目中遇到这样问题的地方就是 比较小的门(棱角那种) 或者这样的树。&&&2.但是还有一些比较特殊的地方,如果你的项目必需使用MeshColider 的话 我建议你写触发脚本来修改摄像机,假设 当摄像机被挡住后,变成跟随视角,只到摄像机没被挡住的时候在回到原来视角。3.我检查了一下上面的代码中我们在加一个判断,应该就可以解决大部分问题、在LateUpdate () 中最后加入代码[代码]:if(!closer)
transform.position =
float dis = Vector3.Distance(transform.position,controller.transform.position);
if(dis & 8)
distance =
}bool closer 是表示是否拉近。 当摄像机被挡住的时候这个数值等于[代码]:if(Physics.Linecast(tirggerTaget,aim,out hit))
string name =
hit.collider.gameObject.
if(name != "MainCamera")
transform.position = hit.
distance = Vector3.Distance(transform.position,controller.transform.position) - 2f;
}当closer等于假的时候,此时直接修更新摄像机的位置,因为没被挡住。 当closer等于真的时候,摄像机已经被挡住了,我们不修改摄像机的位置,计算摄像机保证不被挡住时,摄像机此时和主角的距离是多少,然后修改distance全局变量即可。当摄像机不被遮挡的时候在恢复之前的距离。 如有问题请留言,我会即时解答
站长推荐 /7
在Android Studio中,点击run,到app运行在手机上,之间究竟发生了什么,代码和资源是怎么变成APK的,而APK又是怎么安装上去,并能执行的呢。
全部都是百度网盘下载,包括Android Studio、SDK Tools、反编译工具、调试工具……
支持老罗Android视频,学习Android技术!学习是一种信仰!
技术GG还在愁如何赚安币?不要说我没有告诉你们攻略哦~
基于MVP模式开发的免费下载小说app,采用最流行框架搭建,干货多多,集中最近流行的框架和思维以一种简单易理解的方式实现,方便大家学习
其实每一个巴友都有可能成为最快或最“持久”的人,来吧~看谁是巴士的打卡王~丰富奖品等着你~
Android最新资讯干货,尽在【Bus weekly】}

我要回帖

更多关于 unity摄像机控制脚本 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信