public IEnumerator move_agent_to_vector2()
        {
            // Use the Assert class to test conditions.
            // Use yield to skip a frame.
            AgentConfig config = ScriptableObject.CreateInstance <AgentConfig>();

            config.MovementSpeed   = 1;
            config.UsesRigidbody2D = true;
            GameObject go = new GameObject();

            Agents.Agent agent = go.AddComponent <Agents.Agent>();
            go.AddComponent <Rigidbody2D>();
            MoverFromInput mover = go.AddComponent <MoverFromInput>();

            mover.Init(agent, config);
            go.transform.position = Vector2.zero;
            mover.Move(new Vector2(5, 5));
            yield return(new WaitForSeconds(1f));

            Assert.That((Vector2)go.transform.position != Vector2.zero);

            go.transform.position = Vector2.zero;
            go.GetComponent <Rigidbody2D>().AddForce(new Vector2(5, 5));
            yield return(new WaitForSeconds(1f));

            Assert.That((Vector2)go.transform.position != Vector2.zero);
            Debug.Log(go.transform.position);
        }
Beispiel #2
0
 public void Init(Agents.Agent _agent, AgentConfig _config, Tile _currentTile)
 {
     config                      = _config;
     currentTile                 = _currentTile;
     agent                       = _agent;
     movementSpeed               = config.MovementSpeed;
     detectionSphere             = transform.GetChild(0).transform;
     detectionSphere.localScale *= agent.DetectionRange + 2;
 }