//-------------------------------------------------------------------------------------------------------------- /// <summary> /// This function is called when the script is loaded or a value is changed in the inspector (editor only). /// <para/> /// Use this function to validate the data of your MonoBehaviours. This can be used to ensure that when you /// modify data in an editor that the data stays within a certain range. /// </summary> protected virtual void OnValidate() { if (!Application.isPlaying) { aimContext = GetComponent <AIMContext>(); } }
void Start() { myBody = this.GetComponent <Rigidbody2D>(); anim = this.GetComponent <Animator>(); aimContext = this.GetComponent <AIMContext>(); rend = this.GetComponent <SpriteRenderer>(); CambiarColorEnemy(); }
void Update() { AIMContext aimContext = GetComponent <AIMContext>(); Vector2 target = aimContext.DecidedDirection - transform.position; controller.Move(aimContext.DecidedDirection.x * runSpeed * Time.deltaTime, _crouch, _jump); _jump = false; }
private void OnEnable() { if (Context == null) { Context = GetComponentInChildren <AIMContext>(); } if (Context == null) { enabled = false; } }
private void Start() { // Spawn the entity spawnedEntity = (GameObject)Instantiate(Entity, transform.position, Quaternion.identity); NetworkServer.Spawn(spawnedEntity); AIMContext context = GetComponent <AIMContext>(); // If you want to use this script for you own examples, you have to replace this controller with your own. PhysicsController2D controller = spawnedEntity.GetComponent <PhysicsController2D>(); controller.Context = context; controller.enabled = true; }
//-------------------------------------------------------------------------------------------------------------- /// <summary> /// Awake is called when the script instance is being loaded. /// </summary> protected virtual void Awake() { aimContext = GetComponent <AIMContext>(); aimContext.EvaluationPreparers.Add(this); context = aimContext.Context; Behaviour.Context = context; Behaviour.Order = Order; RegisterBehaviour(); if (!initialized) { Reset(); } gameObject.GetComponents <AIMSeek>(); }
private void OnEnable() { if (Body == null) { Body = gameObject.GetComponentInChildren <Rigidbody>(); } if (Context == null) { Context = gameObject.GetComponentInChildren <AIMContext>(); } // Disable if the setup is invalid. if (Body == null || Context == null) { enabled = false; } }
//-------------------------------------------------------------------------------------------------------------- /// <summary> /// Generates a list containing all objectives currently available within the associated <see cref="Context"/>. /// <para/> /// This may be used as default parametrization for behaviours allowing the use of multiple target objectives, /// like for instance <see cref="PlanarConvolution"/> and <see cref="Retention"/>. /// </summary> /// <returns> /// A list containing all objectives currently available within the associated <see cref="Context"/>. /// </returns> protected List <int> GetDefaultTargetObjectives() { List <int> targetObjectives = new List <int>(); AIMContext aimContext = GetComponent <AIMContext>(); if (aimContext != null) { // The following is ugly but necessary due to Unity's arbitrary order of calling Awake if (aimContext.Context.Problem.ObjectiveCount == 0) { aimContext.BuildContext(); } for (int i = 0; i < aimContext.Context.Problem.ObjectiveCount; i++) { targetObjectives.Add(i); } } return(targetObjectives); }
private void OnEnable() { if (Animator == null) { Animator = GetComponent <Animator>(); } if (Context == null) { Context = GetComponent <AIMContext>(); } if (Context == null || Animator == null) { Debug.LogWarning('(' + typeof(RootMotionController).Name + ") " + name + ": deactivated because a " + "reference to either an AIMContext or an Animator is missing."); enabled = false; return; } Animator.applyRootMotion = true; }