void Update() { if (Input.GetButtonDown("Fire1")) { Collider[] colliders = Physics.OverlapSphere(transform.position + transform.forward + _kickPosition, _kickRadius, _whatToKick); foreach (Collider collider in colliders) { Debug.Log(collider.gameObject); Vector3 moveX = transform.right * _kickDirection.x; Vector3 moveY = transform.up * _kickDirection.y; Vector3 moveZ = transform.forward * _kickDirection.z; Vector3 move = (moveX + moveY + moveZ).normalized; collider.gameObject.GetComponent <Rigidbody>().AddForce(move * _kickPower); TargetAI ai = collider.gameObject.GetComponent <TargetAI>(); if (ai) { ai.Kicked = true; } else { EnemyPursueTarget enemyAI = collider.gameObject.GetComponent <EnemyPursueTarget>(); if (enemyAI) { enemyAI.Kicked = true; } } } } }
public override bool Execute() { Transform player = TargetAI.LookForPlayerArround(TargetAI.DetectRadius); if (player != null) { float d = Vector3.Distance(TargetAI.transform.position, player.position); if (d <= stopDistance) { agent.IsStopped = true; return(false); } if (d <= stopDistance) { agent.IsStopped = true; return(false); } else { if (agent.IsStopped) { agent.StopDistance = stopDistance; agent.IsStopped = false; agent.SetDestination(player.position); } return(true); } } return(false); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { /* * TankAi tankAi = animator.gameObject.GetComponent<TankAi>(); * tankAi.SetNextPoint(); */ TargetAI targetAI = animator.gameObject.GetComponent <TargetAI>(); targetAI.SetNextPoint(); }
public override bool Execute() { Vector3 playerPos = GameObject.Find("Player").transform.position; if (Vector3.Distance(transform.position, playerPos) < 1) { tocando = true; } if (tocando) { print("Te hice daƱo"); GetComponent <AICharacter>().ModifyHP(TargetAI.GetComponent <AICharacter>().HP * -1.0f); print(TargetAI.GetComponent <AICharacter>().HP); } print("estoy tocando:" + tocando); return(tocando); }
private void Cmd_takeHit(int objectID) { foreach (NetworkIdentity identity in Component.FindObjectsOfType <NetworkIdentity>()) { if (identity.netId.Value == objectID) { // Try to get the ai script TargetAI ai = identity.GetComponentInChildren <TargetAI>(); // Check for the target AI component if (ai != null) { // Inform the enemy manager that an enemy has died SpawnableManager.informSpawnableDestroyed(identity.gameObject, true); } break; } } }
private void takeHit(RaycastHit hit) { // Get the game object GameObject hitObject = hit.collider.gameObject; // Find the highest level transform Transform hitRoot = hitObject.transform.root; #if ULTIMATE_SPAWNER_NETWORKED == true NetworkIdentity id = hitRoot.GetComponent <NetworkIdentity>(); // We have hit a static scene object if (id == null) { return; } // We have hit a non-enemy object (Another player) if (id.GetComponent <TargetAI>() == null) { return; } // Kill the enemy Cmd_takeHit((int)id.netId.Value); #else // Try to get the ai script TargetAI ai = hitRoot.GetComponentInChildren <TargetAI>(); // Check for the target AI component if (ai != null) { // Inform the enemy manager that an enemy has died SpawnableManager.informSpawnableDestroyed(hitRoot.gameObject, true); } #endif }
// Methods private void OnControllerColliderHit(ControllerColliderHit hit) { // Get the highest level transform Transform hitRoot = hit.transform.root; // Try to get the target ai script TargetAI ai = hitRoot.GetComponent <TargetAI>(); // Check for component if (ai != null) { // Display a message on screeen DisplayHud.showFadeText("You Died!"); PlayerSpawner spawner = Component.FindObjectOfType <PlayerSpawner>(); // Makes sure we found the spawner if (spawner != null) { // Reposition the player at a spawn point spawner.respawnPlayer(); } } }
public override bool Execute() { if (canAttack == true) { Transform player = TargetAI.LookForPlayerArround(TargetAI.AttackRadius); if (player != null) { Player p = player.GetComponent <Player>(); if (p != null) { canAttack = false; TargetAI.Atack(p); Invoke("resetCD", cD); return(true); } } return(false); } else { return(false); } }
private void Awake() { M_character = TargetAI.GetComponent <AICharacter>(); M_character.OnCollision += ReadCollision; player = FindObjectOfType <Player>().transform; }