手机网站怎么做沉浸式,建大型网站要多少钱,中国seo公司,哪个网站可以查建筑公司资质本文主要总结实现角色移动的解决方案。 1. 创建脚本#xff1a;PlayerController 2. 创建游戏角色Player#xff0c;在Player下挂载PlayerController脚本 3. 把Camera挂载到Player的子物体中#xff0c;调整视角#xff0c;以实现相机跟随效果 3. PlayerController脚本代码…本文主要总结实现角色移动的解决方案。 1. 创建脚本PlayerController 2. 创建游戏角色Player在Player下挂载PlayerController脚本 3. 把Camera挂载到Player的子物体中调整视角以实现相机跟随效果 3. PlayerController脚本代码如下
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class PlayerController : MonoBehaviour
{public float speed 5.0f;// Start is called before the first frame updatevoid Start(){Transform transform GetComponentTransform();}// Update is called once per framevoid Update(){ Move();}private void Move(){float horizontalInput Input.GetAxis(Horizontal);float verticalInput Input.GetAxis(Vertical);Vector3 moveingVec new Vector3(horizontalInput, 0f, verticalInput) * Time.deltaTime * speed;transform.Translate(moveingVec);}
}