fehaar / FFWD

This is the FFWD framework for XNA, that allows you to port Unity3D games to XNA for use on WP7 or XBox360 (XBLIG)
Microsoft Public License
133 stars 36 forks source link

Instance of prefab issue ?? #49

Open pmyn opened 12 years ago

pmyn commented 12 years ago

Hello, i have question about object Instantiate; I have following code :

for (int index = 0; index < Projectiles.Length; index++) { Projectiles[index] = (GameObject)Instantiate(Project, transform.position, transform.rotation); Projectiles[index].SetActiveRecursively(false); Projectiles[index].active = false; } When the projectile i shoot i active object : Projectiles[index].SetActiveRecursively(true); Projectiles[index].active = true; and when is colision with object i do : Projectiles[index].SetActiveRecursively(false); Projectiles[index].active = false;

but in the scene on XNA all projectile is set active to false and i ahve big problem. Can you help me with this issue ?? In unity evrythink is okey.

fehaar commented 12 years ago

So what you say is that the projectile is not activated when the activation code is run? And you say that it is the gameobject that is non-active, not just the rendering?

I will try to make a test scene that does the same as you are doing and see if I can spot the problem. Otherwise, if you can share your code I will be happy to take a look at it.

pmyn commented 12 years ago

Projectile is visible and all work autonomus, diffrent speed etc itp. But when i SetRecursiveState(false) on one projectile, all particle for some millisecond blink but i invoke SetRecursiveState(false) on one projectile. I resolve problem at night by ApplicationSettings.UseFallbackRendering = true; (no blink when deactivated) But when i change color on one projectile (renderer.material, renderer.sharedMaterial) all projectile change color.I post some code (and movie issue effect) when i come back to home. Otherwise great framework :)

fehaar commented 12 years ago

Ok. I had the feeling that this could be a problem in the new renderer. Godd to know that the fallback renderer works at least. The shared material system is not quite done yet, so if you want to avoid the color change issue, you should set a new material for each projectile after the instantiate for the moment.

pmyn commented 12 years ago

I have also OffTopic question : A variable autoDestruct on particle emmiters is work ?? I look in code : if (destroy && autodestruct) {

            Destroy(gameObject);
        }

autodestruct i set to true but destroy always false.

fehaar commented 12 years ago

destroy will be set in FixedUpdate if the Animator have had particles and does not have any active anymore - as far as I can tell. So autodestruct should run when the particle system is done - which will usually only be the case for OneShot systems or if you shut down emission in a script.

Thomas Gravgaard Senior Software Developer Press Play ApS thomas@pressplay.dk +45 26 74 26 74

pmyn commented 12 years ago

yeah, OneShots in set to true. Ok i will work with this, Thanks for answer .

pmyn commented 12 years ago

I see now Unity Exporter don't export OneShots Variable, so it must be set on script :)

fehaar commented 12 years ago

Yeah. It is one of the "internal" Unity variables that you cannot get to in scripts, so we cannot export it. You should use the provided script FFWD_EllipsoidParticleEmitter for exporting that value (and the other hidden particle system values). Just attach it to the same gameobject as your particle system and duplicate the values. Extremely annoying - but better than remembering to do it in code all the time.

pmyn commented 12 years ago

Really Thanks, i don't see before this exporters script ;) Sorry for take a time.