I have an array of players. How can I get my enemy to go to the closest one?
I've tried this: public GameObject[] enemies; public Transform curTarget; public float[] enemyDists; public float curEnemyDist; public int count = 1; // Use this for initialization void Start () { } //...
View ArticleEnemy Spawning
I am trying to get an enemy to spawn in 10 different locations using Vector3 or just anchoring the spawn to an invisible object. I need it so that when a collider, attached to the player, collides with...
View ArticleDetect if GameObject is Touching an Imported Level
I have a bullet that gets shot out of a gun. When I previously used a raycast to instantiate a bullet hole on the wall, it worked perfectly. Now I have a raycast that stops at a wall which is an...
View ArticleEnemy AI is not working as it should be??
This is my script I use for enemy AI to move/attack. The problem here is that when I walk away from the enemy, the attack triggers and deals damage every ms it reaches 1.5. If I stand next to them,...
View ArticleArray - SendMessage to two Targets.
The situation is: I have a melee weapon script - it consists of the Physics Overlap Sphere, in which targets will get Damage, when the Player pushes Fire button. The problem is: I need it to Send...
View ArticleHow to make the other gameObject carry out a function.
I'm making a game where a projectile can hit several things. Depending on the tag, the object that would hit would have a function activated by the projectile. I'm also planning of having several...
View ArticleBullet and Enemy can't collide and execute functions
I've already tagged the gameObjects which is the bullet and enemy with the correct names. They have their own colliders as well with rigidbody too however the bullets will not execute the function to...
View ArticleEnemy units behave normally, until they rotate, then their AI seems to break
I have a turn based strategy game, and the enemy have (very basic)AI. The little units seem to work and behave normally, but once they rotate, their AI seems to blow a fuse and they speed up, go...
View ArticleClosest target acquisition using Physics Overlap Sphere script not working
Hey guys, this is my first post so bear with me ^_^ I'm trying to create a target acquisition script using a physics overlap sphere mechanic. I'm very new to coding so this is the best I could do atm....
View ArticleEnemy's health wont get set from different script.
I'm trying to access the health variable from an EnemyMovement class and apply damage/subtract from that health through a different class. using UnityEngine; using System.Collections; public class...
View ArticleNull reference exception on raycast collider hit? Targetter vs Moving Player
Okay so I have this code that allows this unit to target the player. It uses a ray cast script to do this. However, when I create about 5 of these units and they target the player as I'm moving around...
View ArticleHow to create a simple Enemy AI for a 2D game? Mine isn't working. . .
Okay, I'm working on a new 2D game but I'm using an animated sprite sheet for my enemy's texture so whenever it rotates to follow the player, it shows the other sides of the game object and it looks...
View ArticleProblems with enemy attack script!
I'm trying to make an enemy attack script but keep failing. No methods work, I've tried invokeRepeating, but that wont work properly because I need to be checked constantly, just normal Time.deltaTime...
View ArticleHow do I correctly use SendMessage?
I am trying to create a Boss fight scenario in a topdown shooter in which when the player crosses a boundary, a number of enemies are instantiated, and then when the number of enemies reaches zero,...
View ArticleThe best way to damage an enemy (js)
I've got a game where I shoot a laser at enemy spaceships. Where is the best place for the script that damages the enemy? I could do an OnCollisionEnter on the laser when it hits an enemy and access...
View ArticleMonster Patrolling
Greetings, I'm making a game where there's a monster should be patrolling and chase me when he see me, and leave me if I run away. So far I made the monster chase me when I'm close and stop when i run...
View ArticleProblem with Enemy Shooting in Unity2D
Hello, I'm new to this forum so please be patient. I have a problem where I instantiate a projectile once the player gets close to the enemy. However the same code works when the player shoots. Here's...
View ArticleHow to check where I'm being shot from.
Hey there, So I'm working on an FPS multiplayer game. When a player shoots another player, I am able to tell the player that was shot what gameObject shot them. So that's already working. What I would...
View ArticleMake HUD to show object direction
Hey Unitarians, So what I have is my player which is in the center of my camera view. There are enemies around the scene. I want it so that the camera can display arrows on the screen to show the...
View ArticleThrow the Player from the Enemy away
Hi my english isn't so good but I have a Question. When my Player jumps on the Enemy, I will that the Enemy throw the Player after 2 seconds away. How can I make it, that the Enemy throw the Player away?
View Article