Example #1
0
        public override IEnumerator Enter(Character character, Seat seat)
        {
            using (new TimelineLog(character.name, "LifeRaft.Interaction.Enter", "Enter"))
            {
                Debug.Assert(character != null);
                Debug.Assert(seat != null);

                var navMeshAgent        = character.GetComponent <NavMeshAgent>();
                var rigidbody           = character.GetComponent <Rigidbody>();
                var animationController = character.GetComponent <HumanAnimationController>();

                // navigate to raft
                yield return(character.Navigate(this.transform));

                character.CurrentVehicle = this;

                // board animation
                navMeshAgent.enabled  = false;
                rigidbody.isKinematic = true;
                character.transform.SetParent(this.transform);
                // TODO replace while loop with boarding animation code
                var end = Time.time + 2.0f;
                while (Time.time < end)
                {
                    yield return(null);
                }

                animationController.IsInWater = false;
                animationController.SetIsForwardCrawling(false);
                animationController.SetIsSitting(true);
                yield return(null);

                // TODO add code crawl to sit animation

                // position in raft
                character.transform.SetParent(seat.Transform);
                character.transform.localPosition = Vector3.zero;
                character.transform.localRotation = Quaternion.identity;
            }
        }