- A* version: [5.2.4]
- Unity version: [2022.3.40]
protected override void Start()
{
base.Start();
AI.canMove = false;
AI.updatePosition = true;
AI.updateRotation = false;
}
private void OnAnimatorMove()
{
if (!IsAnimatorMove) return;
Vector3 nextPosition = transform.position;
Quaternion nextRotation = transform.rotation;
AI.MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);
if (!_isSpecialAttack)
{
nextRotation = animator.rootRotation;
}
nextPosition.x = animator.rootPosition.x;
nextPosition.z = animator.rootPosition.z;
transform.rotation = nextRotation;
// Vector3 velocity = animator.deltaPosition / Time.deltaTime;
// velocity.y = nextPosition.y;
// _rvoController.CalculateMovementDelta(Time.deltaTime);
AI.FinalizeMovement(nextPosition, nextRotation);
}
I’m trying to work local avoidance with root motion, but I can’t see a suitable solution in the forum. I know it’s a top-down relationship, but could you please tell me the next best option?
EDIT :
private void OnAnimatorMove()
{
if (!IsAnimatorMove) return;
Vector3 nextPosition = transform.position;
Quaternion nextRotation = transform.rotation;
AI.MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);
if (!_isSpecialAttack)
{
nextRotation = animator.rootRotation;
}
// nextPosition.x = animator.rootPosition.x;
// nextPosition.z = animator.rootPosition.z;
nextPosition.x = transform.position.x + (animator.deltaPosition.x * Time.deltaTime);
nextPosition.z = transform.position.z + (animator.deltaPosition.z * Time.deltaTime);
transform.rotation = nextRotation;
// Vector3 velocity = animator.deltaPosition / Time.deltaTime;
// velocity.y = nextPosition.y;
var delta = _rvoController.CalculateMovementDelta(transform.position, Time.deltaTime);
nextPosition += delta;
// transform.position = nextPosition;
AI.FinalizeMovement(nextPosition, nextRotation);
}
I think it’s okay to do this, is there any problem with doing it like this?