Example #1
0
        public override void OnActivateStay(HedgehogController controller)
        {
            if (controller == null)
            {
                return;
            }

            var index = Controllers.IndexOf(controller);

            if (index < 0)
            {
                return;
            }

            ControllerProgress[index] += TravelSpeed / _cachedLength * Time.fixedDeltaTime;

            var walk = Physics2DUtility.Walk(_cachedPath, ControllerProgress[index], false) +
                       (Vector2)(controller.transform.position - controller.Sensors.Center.position);

            Velocities[index]             = (walk - (Vector2)controller.transform.position) / Time.fixedDeltaTime;
            controller.transform.position = new Vector3(walk.x, walk.y, controller.transform.position.z);

            if (ControllerProgress[index] > 1.0f)
            {
                ObjectTrigger.Deactivate(controller);
            }
        }
Example #2
0
 /// <summary>
 /// Moves the platform to a point on the path.
 /// </summary>
 /// <param name="t">A point on the path, 0 being its start point and 1 being its end point.</param>
 public override void To(float t)
 {
     transform.position = _cachedPath == null
         ? Physics2DUtility.Walk(Path, t)
         : Physics2DUtility.Walk(_cachedPath, t);
 }