Hi… I have 1 script c# put at Enemy… My problem is when enemy1 or 2 or 3 back to active, child not reset to original position. Child have rigidbody and collider. Can somebody help me to reset to original position? this script are inside ‘Enemy’…
Somebody !!! Help me please… - I’m new in UNITY and C# -
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class EnemyList : MonoBehaviour {
public GameObject[] enemys;
public int currentEnemyIndex;
IEnumerator Start (){
LoadEnemy ();
yield return 0;
}
private void BackToMenu (){
Application.LoadLevel ("Menu");
}
public void LoadNextEnemy () {
if (currentEnemyIndex == enemys.Length - 1) {
currentEnemyIndex = 0;
Application.LoadLevel ("Menu");
} else if (currentEnemyIndex >= 0 && currentEnemyIndex < enemys.Length - 1) {
currentEnemyIndex++;
LoadEnemy ();
}
}
//Load the previous enemy
public void LoadPreviousEnemy () {
if (currentEnemyIndex > 0 && currentEnemyIndex < enemys.Length) {
currentEnemyIndex--;
LoadEnemy ();
}
}
//Load the current enemy
private void LoadEnemy () {
if (enemys == null) {
return;
}
if (!(currentEnemyIndex >= 0 && currentEnemyIndex < enemys.Length)) {
return;
}
if (enemys [currentEnemyIndex] == null) {
return;
}
HideEnemys ();
enemys [currentEnemyIndex].SetActive (true);
}
//Hide the enemys
private void HideEnemys (){
if (enemys == null) {
return;
}
foreach (GameObject enemy in enemys) {
if (enemy != null)
enemy.SetActive (false);
}
}
}