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; } } }
protected virtual void OnValidate() { CharacterActor characterActor = this.GetComponentInBranch <CharacterActor>(); if (characterActor == null) { Debug.Log("Warning: No CharacterActor component detected in the root object."); } }
protected virtual void Awake() { CharacterActor = this.GetComponentInBranch <CharacterActor>(); if (CharacterActor != null) { RootController = CharacterActor.GetComponentInChildren <CharacterGraphicsRootController>(); } }
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(); } }
protected virtual void Start() { state = gunStates.idle; characterActor = GameObject.FindWithTag("Player").GetComponent <Lightbug.CharacterControllerPro.Core.CharacterActor>(); }
public virtual void Initialize(CharacterActor characterActor) { this.characterActor = characterActor; }
protected virtual void Awake() { characterActor = this.GetComponentInBranch <CharacterActor>(); }
public void Initialize(CharacterActor characterActor, PhysicsComponent physicsComponent) { this.characterActor = characterActor; this.physicsComponent = physicsComponent; }
// ================================================================================= protected void InitCollisionInfo(CharacterActor Actor, PhysicsComponent PhysicsCompoenent) { characterCollisions.Initialize(Actor, PhysicsCompoenent); }
// Remove actor ----------------------------------------------- public void RemoveActor(CharacterActor characterActor) { characterActors.Remove(characterActor); }
// Add actor ----------------------------------------------- public void AddActor(CharacterActor characterActor) { characterActors.Add(characterActor); }
/// <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); } }