实现宠物跟随移动效果
2017-08-29 20:22
826 查看
宠物身上的脚本
这里没有写玩家移动
using UnityEngine; using System.Collections; public class Follow : MonoBehaviour { //宝宝要跟随的目标 public Transform target; //宝宝跟随目标的偏移量 public Vector3 offset; //宠物在玩家后的距离 public float backDistance = 2; //高度 public float topDistance = 2; //在LateUpdate中进行物理 void LateUpdate() { //设置一个偏移量 offset = -target.forward * backDistance + target.up * topDistance; //使用插值,让宠物有一个平滑的移动 //重点;跟随效果的实现 transform.position = Vector3.Lerp(transform.position, target.position + offset,Time.deltaTime); //让宠物的旋转和玩家的旋转保持一致 transform.rotation = target.rotation; } }
这里没有写玩家移动
相关文章推荐
- js实现的跟随鼠标移动的时钟效果(中英文日期显示)
- javascript实现图片跟随鼠标移动效果的方法
- 实现ViewPager新手引导页的指示点跟随移动的效果
- Android自定义圆形View实现小球跟随手指移动效果
- Android最简单的实现View拖拽跟随手指移动效果
- 原生JS实现的多个彩色小球跟随鼠标移动动画效果示例
- 安卓仿手机QQ消息BadgeView气泡跟随手指移动,并实现进出动画效果。
- js实现的跟随鼠标移动的时钟效果(中英文日期显示)
- unity 实现宠物跟随移动
- 使用JS实现气泡跟随鼠标移动的动画效果
- javascript实现图片跟随鼠标移动效果的方法
- Android实现View拖拽跟随手指移动效果
- JS+html5实现跟随鼠标移动而散开的粒子效果
- 在一个Activity页面中View跟随手指移动,并且能实现点击效果
- 完整的html+css+javascript实现跟随鼠标移动显示选中效果
- Android实现拖动小球跟随手指移动效果
- quick cocos2d-x 实现划线轨迹,精灵匀速跟随移动的效果
- js+css样式表实现鼠标移动变换显示内容效果
- css实现鼠标移动图片居中放大效果
- 粒子从A点移动到B点,拖尾的效果实现