- Home /
Prefab variants inherited scripts
Hi,
Using the new prefab variants system I'm a bit confused concerning script inheritance:
Let's say I have a Character prefab where Character.cs script is attached Now I create a Character's prefab variant Player and Player.cs which inherits Character.cs I have to remove the Character.cs script of Player prefab variant and replace it with Player.cs but it feels kind of wrong isn't there a way to specify script inheritance for instead of getting Character.cs removed, Player.cs added have something like Player.cs (Character.cs) modified in my Player prefab view?
Thanks
Now I create a Character's prefab variant Player and Player.cs which inherits Character.cs
For me -in your stuation- i would keep Character as base class and derive all other variants from that one. So i wouldn't add Character to any prefab directly but i would create derived scripts for each particular prefab (like Character -> Player, NonPlayer etc.).
You mean that Player.cs should not inherit Character.cs ?
One problem with that solution is that it prevents you from hooking up common references in the base prefab.
Yup and i should have clarified that some characters are instantiated in my game, however the player is just like a character but have few more things (like control scripts etc.).
Answer by xbassad · Apr 17, 2019 at 06:02 PM
Check this video,m8 https://www.youtube.com/watch?v=CJvom-afMmE
I watched but unfortunately it doesn't answer my question as this video doesn't address script inheritance in nested prefabs.