Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using Pathfinding.RVO;
- namespace Pathfinding.RVO
- {
- [HelpURL("http://arongranberg.com/astar/docs/class_pathfinding_1_1_examples_1_1_r_v_o_example_agent.php")]
- public class RVORotationUnitPathMovement : RVOUnitSimplePathMovement, IRVOMovement
- {
- #region variables
- // Vlad's extra edit
- private float _initialMaxSpeed;
- private bool _isSlownDown = false;
- private float _minRotationAngle = 46;
- #endregion variables
- #region init
- public override void Start()
- {
- _initialMaxSpeed = maxSpeed;
- }
- #endregion init
- #region override
- public override void AdjustSpeedOnRotation(Vector3 movementDelta)
- {
- float crtAng = RotateInThisDirection(movementDelta);
- float targetAng = Mathf.Atan2(movementDelta.y, movementDelta.x) * Mathf.Rad2Deg;
- if (targetAng < 0) { targetAng += 360; }
- float outComeAngle = Mathf.Abs(targetAng - crtAng);
- if (outComeAngle < _minRotationAngle || (360 - outComeAngle) < _minRotationAngle)
- {
- if (_isSlownDown)
- {
- _isSlownDown = false;
- maxSpeed = _initialMaxSpeed;
- }
- } else {
- if (!_isSlownDown)
- {
- _isSlownDown = true;
- maxSpeed = 0.01f;
- }
- }
- }
- #endregion override
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement