public void SetGroundInfo(Contact contact, CharacterActor characterActor)
        {
            ResetGroundInfo();

            float contactSlopeAngle = Vector3.Angle(characterActor.Up, contact.normal);

            groundContactNormal = contactSlopeAngle < 90f ? contact.normal : characterActor.Up;
            groundContactPoint  = contact.point;

            groundStableNormal = contact.normal;


            groundSlopeAngle = Vector3.Angle(characterActor.Up, groundStableNormal);
            groundObject     = contact.gameObject;

            if (groundObject != null)
            {
                groundLayer      = groundObject.layer;
                groundCollider3D = contact.collider3D;

                if (contact.collider3D != null)
                {
                    groundRigidbody3D = contact.collider3D.attachedRigidbody;
                }
            }
        }
Пример #2
0
        protected virtual void OnValidate()
        {
            CharacterActor characterActor = this.GetComponentInBranch <CharacterActor>();

            if (characterActor == null)
            {
                Debug.Log("Warning: No CharacterActor component detected in the root object.");
            }
        }
Пример #3
0
        protected virtual void Awake()
        {
            CharacterActor = this.GetComponentInBranch <CharacterActor>();

            if (CharacterActor != null)
            {
                RootController = CharacterActor.GetComponentInChildren <CharacterGraphicsRootController>();
            }
        }
Пример #4
0
        protected virtual void OnValidate()
        {
            CharacterActor = this.GetComponentInBranch <CharacterActor>();

            if (CharacterActor == null)
            {
                Debug.Log("Warning: No CharacterActor component detected in this hierarchy.");
            }
            else
            {
                RootController = CharacterActor.GetComponentInChildren <CharacterGraphicsRootController>();
            }
        }
        // ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

        public void SetGroundInfo(CollisionInfo collisionInfo, CharacterActor characterActor)
        {
            if (collisionInfo.collision)
            {
                isOnEdge            = collisionInfo.isAnEdge;
                groundContactNormal = collisionInfo.contactSlopeAngle < 90f ? collisionInfo.hitInfo.normal : characterActor.Up;
                groundContactPoint  = collisionInfo.hitInfo.point;
                groundStableNormal  = characterActor.GetGroundSlopeNormal(collisionInfo);
                groundSlopeAngle    = Vector3.Angle(characterActor.Up, groundStableNormal);

                groundObject = collisionInfo.hitInfo.transform.gameObject;
                groundLayer  = groundObject.layer;

                groundCollider3D  = collisionInfo.hitInfo.collider3D;
                groundRigidbody3D = collisionInfo.hitInfo.rigidbody3D;
            }
            else
            {
                ResetGroundInfo();
            }
        }
Пример #6
0
 protected virtual void Start()
 {
     state          = gunStates.idle;
     characterActor = GameObject.FindWithTag("Player").GetComponent <Lightbug.CharacterControllerPro.Core.CharacterActor>();
 }
Пример #7
0
 public virtual void Initialize(CharacterActor characterActor)
 {
     this.characterActor = characterActor;
 }
Пример #8
0
 protected virtual void Awake()
 {
     characterActor = this.GetComponentInBranch <CharacterActor>();
 }
Пример #9
0
 public void Initialize(CharacterActor characterActor, PhysicsComponent physicsComponent)
 {
     this.characterActor   = characterActor;
     this.physicsComponent = physicsComponent;
 }
        // =================================================================================

        protected void InitCollisionInfo(CharacterActor Actor, PhysicsComponent PhysicsCompoenent)
        {
            characterCollisions.Initialize(Actor, PhysicsCompoenent);
        }
Пример #11
0
 // Remove actor -----------------------------------------------
 public void RemoveActor(CharacterActor characterActor)
 {
     characterActors.Remove(characterActor);
 }
Пример #12
0
        // Add actor -----------------------------------------------

        public void AddActor(CharacterActor characterActor)
        {
            characterActors.Add(characterActor);
        }
Пример #13
0
        /// <summary>
        /// Updates and interpolates all the actors in the scene.
        /// </summary>
        public void Simulate(float dt)
        {
            if (OnSimulationStart != null)
            {
                OnSimulationStart(dt);
            }

            for (int i = 0; i < kinematicPlatforms.Count; i++)
            {
                KinematicPlatform kinematicPlatform = kinematicPlatforms[i];

                if (!kinematicPlatform.enabled)
                {
                    continue;
                }

                kinematicPlatform.UpdateKinematicActor(dt);
            }

            if (OnCharacterSimulationStart != null)
            {
                OnCharacterSimulationStart(dt);
            }

            for (int i = 0; i < characterActors.Count; i++)
            {
                CharacterActor characterActor = characterActors[i];


                if (!characterActor.enabled)
                {
                    continue;
                }

                characterActor.UpdateCharacter(dt);
            }

            if (OnCharacterSimulationEnd != null)
            {
                OnCharacterSimulationEnd(dt);
            }



            // Interpolation ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────

            if (useInterpolation)
            {
                for (int i = 0; i < kinematicPlatforms.Count; i++)
                {
                    KinematicPlatform kinematicPlatform = kinematicPlatforms[i];

                    if (!kinematicPlatform.enabled)
                    {
                        continue;
                    }

                    InterpolateRigidbodyComponent(kinematicPlatform.RigidbodyComponent);
                }

                // for( int i = 0 ; i < characterActors.Count ; i++ )
                // {
                //     CharacterActor characterActor = characterActors[i];

                //     if( !characterActor.enabled || !characterActor.IsKinematic )
                //         continue;

                //     InterpolateRigidbodyComponent( characterActor.RigidbodyComponent );
                // }
            }


            if (OnSimulationEnd != null)
            {
                OnSimulationEnd(dt);
            }
        }