/// <summary> /// Set the ship meshes / materials /// </summary> /// <remarks>This only runs on adding a script in editor</remarks> public override void Reset() { // Base setup base.Reset(); // Set the collider CapsuleCollider cc = this.GetComponent <CapsuleCollider>(); cc.center = new Vector3(0f, 0f, 2.33f); cc.radius = 12f; cc.height = 40f; cc.direction = 2; // Set the collision radius Apex.Units.UnitComponent uc = this.GetComponent <Apex.Units.UnitComponent>(); uc.fieldOfView = 200; uc.radius = 12f; uc.determination = 1; }
public void CloneFrom(UnitComponent unitComp) { _isSelectable = unitComp.isSelectable; this.selectionVisual = unitComp.selectionVisual; _heightCapabilities = unitComp._heightCapabilities; _effectiveHeightCapabilities = unitComp._effectiveHeightCapabilities; this.radius = unitComp.radius; this.fieldOfView = unitComp.fieldOfView; this.baseToPositionOffset = unitComp.baseToPositionOffset; this.height = unitComp.height; this.yAxisoffset = unitComp.yAxisoffset; }
/// <summary> /// Called on Awake /// </summary> protected virtual void Awake() { this.transformCached = this.transform; _unit = this.GetComponent<UnitComponent>(); }
private void Awake() { this.WarnIfMultipleInstances(); _transform = this.transform; _facingOrientation = new FacingOrientation { priority = this.turnRequestPriority, turnSpeed = this.turnSpeed }; //Get the speed source _speedSource = this.As<IDefineSpeed>(); if (_speedSource == null) { Debug.LogError("A speed source component is required to steer."); this.enabled = false; } //Resolve the mover _mover = this.As<IMoveUnits>(); if (_mover == null) { var fact = this.As<IMoveUnitsFactory>(); var charController = this.GetComponent<CharacterController>(); if (fact != null) { _mover = fact.Create(); } else if (charController != null) { _mover = new CharacterControllerMover(charController); } else if (this.rigidbody != null) { _mover = new RigidBodyMover(_transform, this.rigidbody); } else { _mover = new DefaultMover(_transform); } } _unit = this.GetComponent<UnitComponent>(); _steeringComponents = new List<SteeringComponent>(); _minimumSpeedToTurnSquared = this.minimumSpeedToTurn * this.minimumSpeedToTurn; _stopped = true; }