Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

45 行
1.2 KiB

// using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleNPC : MonoBehaviour
{
public Transform target;
private Rigidbody rb;
public float walkSpeed = 1;
// public ForceMode walkForceMode;
private Vector3 dirToGo;
// private Vector3 m_StartingPos;
// Start is called before the first frame update
void Awake()
{
rb = GetComponent<Rigidbody>();
// m_StartingPos = transform.position;
}
// Update is called once per frame
void Update()
{
}
void FixedUpdate()
{
dirToGo = target.position - transform.position;
dirToGo.y = 0;
rb.rotation = Quaternion.LookRotation(dirToGo);
// rb.AddForce(dirToGo.normalized * walkSpeed * Time.fixedDeltaTime, walkForceMode);
// rb.MovePosition(rb.transform.TransformDirection(Vector3.forward * walkSpeed * Time.deltaTime));
// rb.MovePosition(rb.transform.TransformVector() (Vector3.forward * walkSpeed * Time.deltaTime));
rb.MovePosition(transform.position + transform.forward * walkSpeed * Time.deltaTime);
}
public void SetRandomWalkSpeed()
{
walkSpeed = Random.Range(6f, 7f);
}
}