コード例 #1
0
        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
ファイル: CharacterGraphics.cs プロジェクト: Hengle/Test
        protected virtual void Awake()
        {
            CharacterActor = this.GetComponentInBranch <CharacterActor>();

            if (CharacterActor != null)
            {
                RootController = CharacterActor.GetComponentInChildren <CharacterGraphicsRootController>();
            }
        }
コード例 #4
0
ファイル: CharacterGraphics.cs プロジェクト: Hengle/Test
        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>();
            }
        }
コード例 #5
0
        // ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

        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
ファイル: S_Gun.cs プロジェクト: nicorivas/game1
 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;
 }
コード例 #10
0
        // =================================================================================

        protected void InitCollisionInfo(CharacterActor Actor, PhysicsComponent PhysicsCompoenent)
        {
            characterCollisions.Initialize(Actor, PhysicsCompoenent);
        }
コード例 #11
0
ファイル: SceneController.cs プロジェクト: nicorivas/game1
 // Remove actor -----------------------------------------------
 public void RemoveActor(CharacterActor characterActor)
 {
     characterActors.Remove(characterActor);
 }
コード例 #12
0
ファイル: SceneController.cs プロジェクト: nicorivas/game1
        // Add actor -----------------------------------------------

        public void AddActor(CharacterActor characterActor)
        {
            characterActors.Add(characterActor);
        }
コード例 #13
0
ファイル: SceneController.cs プロジェクト: nicorivas/game1
        /// <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);
            }
        }