PlayerMove(自动寻路网格,鼠标单击移动,动画速度值绑定)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class PlayerMove : MonoBehaviour
{
// Start is called before the first frame update
public NavMeshAgent agent;
public Animator anim;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
agent.SetDestination(hit.point);
}
}
anim.SetFloat("speed", agent.velocity.magnitude);
}
动画绑定
先在assets中创建animator controller拖入物体的animator组件中->绑定动作->设置边界值
引擎中动画创建
选中需要创建动画的物体->animation窗口->左侧选择需要创建动画的项->右侧打关键帧
粒子系统
图片如何变为粒子?->inspector中shader变为particles/standard Unlit ->粒子系统中的 texture sheet animation
灯光烘焙
物体变为static -> 灯光变为baked ->在lighting中点generate lighting
自动寻路网格
可穿过物体->inspector中navigation static取消勾选
无需构件网格物体->navigation菜单栏 选 not walkable