Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AgentCustomLinkMovement.cs 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Collections;
  2. using NUnit.Framework;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.TestTools;
  6. using UnityEngine.TestTools.Utils;
  7. namespace Unity.AI.Navigation.Tests
  8. {
  9. [TestFixture]
  10. [Category("RegressionTest")]
  11. [PrebuildSetup("Unity.AI.Navigation.Tests." + nameof(SimpleScene2PlanesNavigationSetup))]
  12. [PostBuildCleanup("Unity.AI.Navigation.Tests." + nameof(SimpleScene2PlanesNavigationSetup))]
  13. class AgentCustomLinkMovement : OffMeshLinkTestBase
  14. {
  15. const string k_SceneName = "OffMeshLinkTwoPlanesScene";
  16. [UnitySetUp]
  17. public IEnumerator UnitySetUp()
  18. {
  19. yield return SceneManager.LoadSceneAsync(k_SceneName, LoadSceneMode.Additive);
  20. yield return null;
  21. SceneManager.SetActiveScene(SceneManager.GetSceneByName(k_SceneName));
  22. }
  23. [UnityTest]
  24. [UnityPlatform(exclude = new[] { RuntimePlatform.OSXServer, RuntimePlatform.WindowsServer, RuntimePlatform.LinuxServer })] //MTT-4133 Fails on Dedicated Server
  25. public IEnumerator Agent_WithoutAutoTraverseOnOffMeshLink_DoesNotMoveByItself()
  26. {
  27. var link = CreateBiDirectionalLink(true);
  28. m_Agent.autoTraverseOffMeshLink = false;
  29. m_Agent.baseOffset = 1.0f;
  30. m_Agent.transform.position = link.startTransform.position;
  31. var hasDestination = m_Agent.SetDestination(link.endTransform.position);
  32. Assert.That(hasDestination, Is.True, "NavMeshAgent destination has not been set.");
  33. yield return null;
  34. Assert.That(m_Agent.isOnOffMeshLink, Is.True, "NavMeshAgent is currently not positioned on NavMeshLink.");
  35. // Move to gap between the navmeshes connected by the NavMeshLink
  36. var midAirPosition = new Vector3(17.71f, 3.92f, -6.66f);
  37. m_Agent.transform.position = midAirPosition;
  38. yield return null;
  39. // Ensure the agent stays at this position - as 'autoTraverseOffMeshLink' is false
  40. Assert.That(m_Agent.transform.position, Is.EqualTo(midAirPosition).Using(new Vector3EqualityComparer(0.01f)), "NavMeshAgent should be at midAirPosition.");
  41. }
  42. [UnityTearDown]
  43. public IEnumerator UnityTearDown()
  44. {
  45. yield return SceneManager.UnloadSceneAsync(k_SceneName);
  46. }
  47. }
  48. }