#Particle Instantiate Not Appearing
1 messages · Page 1 of 1 (latest)
Yeah I can preview it and it seems to work normally. The documentation is a little poor but there is a sample scene included with the asset that works like a charm. This is the code that is used in the sample scene
void MakeObject()
{
DestroyGameObject();
gm = Instantiate(m_effects[index],
m_effects[index].transform.position,
m_effects[index].transform.rotation).gameObject;
m_effectName.text = (index+1) +" : "+m_effects[index].name.ToString();
scaleform.transform.position = gm.transform.position;
gm.transform.parent = scaleform.transform;
gm.transform.localScale = new Vector3(1,1,1);
float submit_scalefactor = m_gaph_scenesizefactor;
if (index < 70)
submit_scalefactor *= 0.5f;
gm.transform.localScale = new Vector3(submit_scalefactor, submit_scalefactor, submit_scalefactor);
m_destroyObjects[inputLocation] = gm;
inputLocation++;
}
So, do you need to load it dynamically from resources? Why not just drag the prefab into your scene?
The use case is I have a bunch of cards that will play effects on abilities or on attack. I expect I will have a lot of them. Might be worth testing with 1 just to see but I don't think the problem is on the load part. I have a similar process for creating the cards that works well.
Where do you call CreateEffect? Might shed some light on wether it sticks around long enough to be visible
It's run from a coroutine right now (the whole card attack process is a little in flux)
Doesn't Instantiating a gameObject add it to the scene and then it observes normal lifecycle?
IEnumerator doCardActions(Card[] turnPlayerCards, Card[] defensivePlayerCards){
Debug.Log("Do Card Actions");
for (int i = 0; i < turnPlayerCards.Length; i++){
Debug.Log("in for loop");
Card currentCard = turnPlayerCards[i];
currentCard.CreateAttackEffect();
//do skills for cards [i]
//attack opponent card
if(defensivePlayerCards != null && defensivePlayerCards.Length >= i){
defensivePlayerCards[i].handleCardEvent(new CardEvent(currentCard, CardEvent.Type.DAMAGE, currentCard.Attack, CardEvent.Target.ENEMY_OPPOSITE));
} else {
//TODO:attack opposing player
}
yield return new WaitForSeconds(.5f);
}
}
And then the battle loop
IEnumerator BattleLoop(){
Debug.Log("BattleLoop");
if(battleStart){
if(playerTurn){
drawPlayerCard();
StartCoroutine(doCardActions(playerBattlefield.GetComponentsInChildren<Card>(), opponentBattlefield.GetComponentsInChildren<Card>()));
playerTurn = !playerTurn; //pass the turn
} else {
drawOpponentCard();
StartCoroutine(doCardActions(opponentBattlefield.GetComponentsInChildren<Card>(), playerBattlefield.GetComponentsInChildren<Card>()));
playerTurn = !playerTurn; //pass the turn
}
} else {
battleStart = true;
}
hasPlayedCard = false;
if(!playerTurn){
yield return new WaitForSeconds(2.5f); //amount of time AI waits to play a card
}
yield return new WaitUntil(hasTakenTurn);
StartCoroutine("BattleLoop");
}
create attack effect on the card just calls
public void CreateAttackEffect(){
EffectManager.CreateEffect(gameObject);
}
Was checking to see if it were assigned as a child object to something, or if the scene changed, which it doesn't seem to be. Are there any other scripts on your Prefab? Do you get the logs you expect when you spawn it?
No scripts on the prefab. It's just a couple of top level holders and a bunch of particle children.
Logs look exactly like I would expect if it would work
I wonder if maybe something is wrong with the scale or if its spawning under the card. Also possible something is wrong with my renderer or something (or even a webgl specific issue)
I don't really know anything about WebGL, but try dragging that prefab into the game while it's running in the editor? See if it plays then
Interesting. That doesn't work either so something has to be wrong with the prefab (or I'm missing some dependency or config)
Take a look at the object in the scene while the game is running.
- Make sure it is where you expect it to be and not offset by some distance
- Make sure it's active and all components are enabled
- Make sure the particle system component is still set to
Play on Awake
Awesome. I think I have something to work with. When I drag it into the login screen it ends up behind the parent so something is wrong with that. Then when I hide the image component of the parent it was really small. I think I can get it to work from here. Thanks so much!