Beispiel #1
0
		public void ChooseAction(AIController controller)
		{
			Vector3 opponentDistance = controller.GetOpponentDistance();
			if (Mathf.Abs(opponentDistance.x) > targetDistance) 
			{
				controller.SetRunInDirection(opponentDistance.x);
				// Don't chase an opponent off the map.
				RaycastHit hit = new RaycastHit();
				Vector3 offsetPosition = controller.transform.position;
				offsetPosition.x += controller.runSpeed;
				if (!Physics.Raycast(offsetPosition, Vector3.down, out hit, 100, 1 << 13)) {
					controller.runSpeed = 0;
				}
			} else {
				controller.runSpeed = 0;
			}
		}
Beispiel #2
0
        /// <summary>
        /// Picks an action for the character to do every tick.
        /// </summary>
        /// <param name="controller">The controller for the character.</param>
        public void ChooseAction(AIController controller)
        {
            Vector3 opponentDistance   = controller.GetOpponentDistance();
            float   horizontalDistance = Mathf.Abs(opponentDistance.x);

            if (horizontalDistance > targetDistance)
            {
                controller.SetRunInDirection(opponentDistance.x);
            }
            else if (horizontalDistance < targetDistance - 1f)
            {
                controller.SetRunInDirection(-opponentDistance.x);
            }
            else
            {
                controller.runSpeed = 0;
            }
            if (controller.runSpeed != 0)
            {
                // Don't chase an opponent off the map.
                RaycastHit hit            = new RaycastHit();
                Vector3    offsetPosition = controller.transform.position;
                offsetPosition.x += controller.runSpeed;
                offsetPosition.y += 0.5f;
                if (!Physics.Raycast(offsetPosition, Vector3.down, out hit, 100, 1 << 13))
                {
                    if (controller.ParkourComponent.Sliding)
                    {
                        controller.SetRunInDirection(-opponentDistance.x);
                    }
                    else
                    {
                        controller.runSpeed = 0;
                    }
                    controller.slide = false;
                }
                else
                {
                    controller.slide = horizontalDistance > targetDistance * 2;
                }
            }
        }
Beispiel #3
0
        public void ChooseAction(AIController controller)
        {
            Vector3 opponentDistance = controller.GetOpponentDistance();

            if (Mathf.Abs(opponentDistance.x) > targetDistance)
            {
                controller.SetRunInDirection(opponentDistance.x);
                // Don't chase an opponent off the map.
                RaycastHit hit            = new RaycastHit();
                Vector3    offsetPosition = controller.transform.position;
                offsetPosition.x += controller.runSpeed;
                if (!Physics.Raycast(offsetPosition, Vector3.down, out hit, 100, 1 << 13))
                {
                    controller.runSpeed = 0;
                }
            }
            else
            {
                controller.runSpeed = 0;
            }
        }
Beispiel #4
0
		/// <summary>
		/// Picks an action for the character to do every tick.
		/// </summary>
		/// <param name="controller">The controller for the character.</param>
		public void ChooseAction(AIController controller)
		{
			Vector3 opponentDistance = controller.GetOpponentDistance();
			float horizontalDistance = Mathf.Abs(opponentDistance.x);
			if (horizontalDistance > targetDistance)
			{
				controller.SetRunInDirection(opponentDistance.x);
			}
			else if (horizontalDistance < targetDistance - 1f)
			{
				controller.SetRunInDirection(-opponentDistance.x);
			}
			else
			{
				controller.runSpeed = 0;
			}
			if (controller.runSpeed != 0) {
				// Don't chase an opponent off the map.
				RaycastHit hit = new RaycastHit();
				Vector3 offsetPosition = controller.transform.position;
				offsetPosition.x += controller.runSpeed;
				offsetPosition.y += 0.5f;
				if (!Physics.Raycast(offsetPosition, Vector3.down, out hit, 100, 1 << 13))
				{
					if (controller.ParkourComponent.Sliding)
					{
						controller.SetRunInDirection(-opponentDistance.x);
					}
					else
					{
						controller.runSpeed = 0;
					}
					controller.slide = false;
				}
				else
				{
					controller.slide = horizontalDistance > targetDistance * 2;
				}
			}
		}