using UnityEngine;using System.Collections;public class CameraFollows : MonoBehaviour {private Vector3 position;public Transform target; public float distance ; public float targetHeight; public float PitchAngle; private float x = 0.0f; private float y = 0.0f; private float cameraShakeImpulse; void Start () { var angles = transform.eulerAngles; x = angles.x; y = angles.y;cameraShakeImpulse= 1; } void LateUpdate () { if(!target) return; y = target.eulerAngles.y; Quaternion rotation = Quaternion.Euler(x-PitchAngle, y, 0); transform.rotation = rotation; Vector3 position = target.position - (rotation * Vector3.forward * distance new Vector3(0,-targetHeight,0)); transform.position = position ;ShakeCamera ();print (transform .position);}//摄像机震动void ShakeCamera (){transform.position = new Vector3 (0, Random.Range (-cameraShakeImpulse, cameraShakeImpulse), Random.Range (-cameraShakeImpulse, cameraShakeImpulse));cameraShakeImpulse -= Time.deltaTime * cameraShakeImpulse * 4f;if (cameraShakeImpulse < 0.f) {cameraShakeImpulse = 0;}}
推荐整理分享摄像机跟随与摄像机晃动(摄像机跟随与摄像的区别),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:监控跟随拍摄,摄像机 跟踪,摄像机自动跟随,摄像机 跟踪,摄像机跟随与摄像的区别,摄像机 跟踪,摄像机跟随与摄像头区别,摄像机跟随与摄像头区别,内容如对您有帮助,希望把文章链接给更多的朋友!
当前动画的控制 //stateInfo.fullPathHash:判断当前动画状态;Animator.StringToHash(BaseLayer.Kick):获取kick动画的序列号;!anim.IsInTransition(0):触发的动画不是当前状态的动画时
控制角色jump //控制角色向上跳跃IEnumeratorJumpMove(){floatcurrentHeight=0;rig.useGravity=false;while(currentHeightjumpHeight){transform.position=Vector3.up*jumpPower*Time.deltaTime;currentHeight=jumpPower*
控制角色平滑转弯 //控制角色进行向左或向右的度旋转IEnumeratorRotateDirection(boolisLeft){isRotate=true;intdirection=0;if(isLeft){direction=-1;}else{direction=1;}floatrotateAngles=f;while(rotateAngles