Im trying to move my pokemon game object to the enemy podium but it doesnt work
Hi, Im following this guy's tutorials: https://www.youtube.com/watch?v=l6XiJaKSZ8U
In his tutorials he makes the game 2d, but i make the whole game 3d. So far, everything works except putting the right pokemon on the battle podium.
This is my whole code for GameManager:
public class GameManager : MonoBehaviour {
public GameObject playerCamera;
public GameObject battleCamera;
public GameObject player;
public List<BaseZakMonsters> allZakMonsters = new List<BaseZakMonsters>();
public List<ZakMonsterMoves> allMoves = new List<ZakMonsterMoves>();
public Transform enemyPodium;
public Transform friendlyPodium;
public GameObject emptyMonster;
void Start ()
{
playerCamera.SetActive(true);
battleCamera.SetActive(false);
}
void Update () {
}
public void EnterBattle(Rarity rarity)
{
playerCamera.SetActive(false);
battleCamera.SetActive(true);
BaseZakMonsters battleZakMonsters = GetRandomZakMonsterFromList(GetZakMonsterByRarity(rarity));
Debug.Log(battleZakMonsters.name);
player.GetComponent<Player>().canMove = false;
GameObject dMonster = Instantiate(emptyMonster, enemyPodium.transform.position, Quaternion.identity) as GameObject;
dMonster.transform.parent = enemyPodium;
BaseZakMonsters tempMonster = dMonster.AddComponent<BaseZakMonsters>() as BaseZakMonsters;
tempMonster = battleZakMonsters;
dMonster.GetComponent<BaseZakMonsters>().ZakMonster = battleZakMonsters.ZakMonster;
}
public List<BaseZakMonsters> GetZakMonsterByRarity(Rarity rarity)
{
List<BaseZakMonsters> returnZakMonsters = new List<BaseZakMonsters>();
foreach (BaseZakMonsters ZakMonsters in allZakMonsters)
{
if (ZakMonsters.rarity == rarity)
returnZakMonsters.Add(ZakMonsters);
}
return returnZakMonsters;
}
public BaseZakMonsters GetRandomZakMonsterFromList(List<BaseZakMonsters> monsterList)
{
BaseZakMonsters monster = new BaseZakMonsters();
int monsterIndex = Random.Range(0, monsterList.Count - 1);
monster = monsterList[monsterIndex];
return monster;
}
}
[System.Serializable] public class ZakMonsterMoves { string Name; public MoveType category; public Stat moveStat; public ZakMonsterType moveType; public int PP; public float Power; public float accuracy; }
[System.Serializable] public class Stat { public float minimum; public float maximum; }
public enum MoveType { Physical, Special, Status }
This part for entering battle:
public void EnterBattle(Rarity rarity) { playerCamera.SetActive(false); battleCamera.SetActive(true);
BaseZakMonsters battleZakMonsters = GetRandomZakMonsterFromList(GetZakMonsterByRarity(rarity));
Debug.Log(battleZakMonsters.name);
player.GetComponent<Player>().canMove = false;
GameObject dMonster = Instantiate(emptyMonster, enemyPodium.transform.position, Quaternion.identity) as GameObject;
dMonster.transform.parent = enemyPodium;
BaseZakMonsters tempMonster = dMonster.AddComponent<BaseZakMonsters>() as BaseZakMonsters;
tempMonster = battleZakMonsters;
dMonster.GetComponent<BaseZakMonsters>().ZakMonster = battleZakMonsters.ZakMonster;
}
and this is the line i did different:
dMonster.GetComponent().ZakMonster = battleZakMonsters.ZakMonster;
The guy from the tutorial uses a sprite renderer because its 2d and the line he used looks like this:
dPoke.GetComponent().sprite = battlePokemon.image;
am i doing something wrong here? the only thing i did different is using a GameObject instead of a sprite. Is it even possible to do this with a GameObject? or is it only possible with a sprite?
ZakMonsters is the name i use for Pokemon.
Please help!
Your answer
Follow this Question
Related Questions
Display pictures in assets folder in random order 0 Answers
Coin Flip not working 0 Answers
Random Number every 5 seconds 2 Answers
Help with Randomized Sprite on GUI button click 0 Answers
Randomly generate blocks on a flat map 0 Answers