Projectile Parent Issue, any help appreciated

Having an issue with Glitch Garden which has me pretty frustrated, have been through code numerous times and can see no mistakes at all and matches the code given perfectly as far as I can tell, however while defenders launch projectiles I am getting a weird behaviours.

The projectiles are not becoming a child to the Projectiles game object as they should, and I am getting the error message in the console saying “Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption”

The code looks spot on as far as I can tell, and I am dragging prefabs to prefabs so cannot work this out at all, below is image of the error warning log, and code it leads back to is identical to the code given by Ben in the lecture

Thanks Guys

4 Likes

Update

Stripped out all prefabs and did them again, making sure that prefabs were used and not instances of the object. Also checked code against the course git hub repository and everything checks out with that. Really banging my head against the wall with it now

Hi Dan,

It would help if you shared the code that you’re using to set the parent. From what you’re saying I’d take a shot in the dark and say you’re trying to do something like setting the parent of the prefab, not the object you’re instantiating off of it.

-Frank

Hi Frank

Thank you for getting back to me, I am slowly losing the will to live with this problem :slight_smile:

Here is the code used to set the parent

On the surface it looks right to me. It sounds weird, but is there any chance that projectileParent is a prefab? Beyond that, I can’t see anything that could be wrong with it.

The only prefab associated with it is the projectiles game object to contain the instantiated projectiles in the hierarchy which is dragged and dropped into the public projectileParent on the shooter script in the inspector along with the Projectile and Gun

I have just been reading about a bug in Unity 4.6.3 that can cause this so just trying a newer version of Unity 4 to see if that fixes the issues.

Of course I wasn’t that lucky, error still exists in 4.6.9

Here is screenshot of editor to see if you can see anything obvious there, can easily do other screenshots if you need them

Well… Have you tried using Transform.SetParent instead? I’m still at the Laser defender class but I’ve been doing plenty of modifications to my game, and I used the SetParent method to attach a gameobject to another

Thanks for all the help, turns out there is a fix later in the project where I need to find the component for the parent projectile in the start method. Thanks again

1 Like

I’m glad to hear that you solved it! congrats

Hi, which lesson is the solution in?

The solution is in video #163 in case anyone have the same issue in the future

6 Likes

I watched video 163 and did not see the solution. Could someone post it here for others who get this error.

I’ve been beating me head, asking rubber duck and still no solution to this issue that I can discover on my own.

Dan I’m getting the same error, I am past video 163 and did not see a solution for this error that pops up after making the projectiles object a Prefab. Can you post your solution here, I must have missed something now I’m racking my head trying to figure it out.

Thank you,
John Cordeiro

Found it the solutions is actually Video 164.

3 Likes

Hi all,

I think another video was added or something else happened, but the solution can now be found in video 165.

4 Likes

Please let me know what the solution is. I fixed it after reading some info on the Unity site, but I’m not sure if that is really the correct solution. It had me replace the code for parent to be the following in the fire() method:
newProjectile.transform.parent = transform;

1 Like

For anyone who is looking for the solution it is now in video 167. ‘Creating When Needed’.

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms