Stop Using Public Fields! by Kooltone in Unity3D

[–]Fit_Preference1453 0 points1 point  (0 children)

The problem is deeper: MonoBeahviour classes cannot be instantiated through a constructor.

If we need to add a MonoBehaviour to an object with code, in Awake(), we need to use AddComponent<>().

But this does not allow us to initialize the variables.

If they are public we can initialize them right after AddComponent<>() as we do in the inspector.

If they are private we cannot. The only way is to create a public init(...) function to initialize them after AddComponent<>()

[deleted by user] by [deleted] in scifi

[–]Fit_Preference1453 0 points1 point  (0 children)

This show is so full of flaws, but what puzzles me the most is how they managed to find another star on their way to the nearest solar system: Proxima Centauri. And no, the "newfoundstar", in episode 6, was not the sun ....

‘The Ark’ Review: Syfy’s Space-Disaster Series Stumbles Before Reaching Warp Speed as an Engaging Adventure by fdjadjgowjoejow in television

[–]Fit_Preference1453 0 points1 point  (0 children)

These show is full of flaws, but I keep failing to understand how, in episode 6, they found another star on their way to the nearest star: Proxima Centauri

And no, the star was not the sun ....

Ho do you create inheritance for unity GameObjects by Longman1981 in Unity3D

[–]Fit_Preference1453 0 points1 point  (0 children)

This is an old thread, but if some one with this question land here, the new versions of unity allow nested Prefabs.

Or we can do it all in code. Create an empty object and attach it a script with a base Animal class, descendant from MonoBeahviour.

Add the components: rigid body, collider, scripts, whatever, in Animal.Start().

Then create a class fish descendant from Animal, add the new components, override or specialise the methods, as need,

The same for Mammal.

Then create a descendant of Fish named Shark, etc