I'm ingrained in OO design and I just can't wrap my head around MonoBehaviours. I need my objects to have constructors. I just have one Empty GameObject with a MonoBehaviour script that contains all of my game logic and instantiate everything in script.
Figures. It's not that I don't want to. I have tried to convert my code to using MonoBehaviours a couple of times, but I am always unable to find a suitable alternative to constructors. I need to create objects procedurally, so I can't just give them public fields and play with them in the editor. At the moment, I only modify materials in the editor.Programmer OCD .
I had similar issues when starting Unity. Trust me you are losing a lot of the benefits of the Editor doing everything in code.
Figures. It's not that I don't want to. I have tried to convert my code to using MonoBehaviours a couple of times, but I am always unable to find a suitable alternative to constructors. I need to create objects procedurally, so I can't just give them public fields and play with them in the editor. At the moment, I only modify materials in the editor.
I meant constructors with parameters. I'm aware of Start() but that's not enough.Monobehaviours can have constructors. Its still a class. As far as im aware its:
Constructor functions
Awake functions
--- Scene loads ----
Start functions
Or is the problem based on instantiation order?
I'm ingrained in OO design and I just can't wrap my head around MonoBehaviours. I need my objects to have constructors. I just have one Empty GameObject with a MonoBehaviour script that contains all of my game logic and instantiate everything in script.
Yes, I use prefabs for models. I need the constructor to pass in references and dynamically generated properties. I can get a reference the MonoBehaviour way with GetComponent<T>(), but this is unhelpful if I have multiple instances of the same component attached to the same GameObject but need to find a specific one.Sorry, but this makes little sense. I also come from a OOP background and it helps a lot because in Unity you can actually see the objects and their properties in the editor and the Scene view, you just need to make them interact.
Usually I make a "Scene" object that has a "SceneController" script, this keeps control of the general behaviour of the scenario and the GUI but individual behaviours I try to keep them separated in a logic order.
Are you familiarized with prefabs?
Yes, I use prefabs for models. I need the constructor to pass in references and dynamically generated properties. I can get a reference the MonoBehaviour way with GetComponent<T>(), but this is unhelpful if I have multiple instances of the same component attached to the same GameObject but need to find a specific one.
Packt 5 for $50 deal.
may come in handy?
http://www.packtpub.com/gamedevoffe...6cdf9f44852f8d05e&utm_source=Campaign Monitor
know any of these books? are they worth it?
Yes, I use prefabs for models. I need the constructor to pass in references and dynamically generated properties. I can get a reference the MonoBehaviour way with GetComponent<T>(), but this is unhelpful if I have multiple instances of the same component attached to the same GameObject but need to find a specific one.
know any of these books? are they worth it?
Figures. It's not that I don't want to. I have tried to convert my code to using MonoBehaviours a couple of times, but I am always unable to find a suitable alternative to constructors.
Why is there such a collective hard on for video tutorials for something like programming? I feel like it's horribly time inefficient, you can't skip around, you can't easily reference stuff, you have to go at whatever (usually slow) pace they talk at etc.
Trying to make a Gone Home clone?Gowans said:All I'm looking to create is a 3d house I can walk around it.
Anyone have any tutorial suggestions for that?
Guess I'll also need to model it too, any program advice?
Figures. It's not that I don't want to. I have tried to convert my code to using MonoBehaviours a couple of times, but I am always unable to find a suitable alternative to constructors. I need to create objects procedurally, so I can't just give them public fields and play with them in the editor. At the moment, I only modify materials in the editor.
Just write an init or factory method that takes whatever params you need to send to it.
For some classes that I want to have MonoBehaviour capabilities I do something similar to this:
Code:class SomeClass : MonoBehaviour { object [] parameters; public static SomeClass Construct(object [] parameters) { GameObject someClassObject = new GameObject("SomeClassObject"); SomeClass constructed = someClassObject.AddComponent<SomeClass>(); constructed.parameters = parameters; return constructed; } }
I must be being very unclear. I don't want duplicate scripts. I want duplicate Units, with references to the Map they're on and the Player that owns them. So I instantiate them in my gamelogic with new Unit(map, player). From what I understand, the MonoBehaviour way to do this is add the Player as a component to the Map, and add the Unit as a component to the Player. This is fine if I only have one of each, but I have multiple Players who own multiple Units, and GetComponent<T>() is fruitless for finding the right one.Why do you have duplicate scripts attached to an object?
Okay, I think I understand. I thought it was impossible because they can't be instantiated with the new keyword, but I could try this.Just write an init or factory method that takes whatever params you need to send to it.
For some classes that I want to have MonoBehaviour capabilities I do something similar to this:
I must be being very unclear. I don't want duplicate scripts. I want duplicate Units, with references to the Map they're on and the Player that owns them. So I instantiate them in my gamelogic with new Unit(map, player). From what I understand, the MonoBehaviour way to do this is add the Player as a component to the Map, and add the Unit as a component to the Player. This is fine if I only have one of each, but I have multiple Players who own multiple Units, and GetComponent<T>() is fruitless for finding the right one.
Okay, I think I understand. I thought it was impossible because they can't be instantiated with the new keyword, but I could try this.
Do yourselves a favor and script in C# please.
I've been working with and testing RPG Maker VX Ave for a 2D Rpg, but I was wondering if thrre was anything better to use? I can't code worth a damn, so RmVXACE has been doing great for me so far.
Is Unity really good with 2D? Easy to work with?
C# is certainly important if you plan to work for others in the future, but if you are already somewhat familiar with javascript, I recommend just continuing to use that for now, most of what you learn for one object oriented language like javascript can easily be retained when/if you move over to C#.
There is also no real advantage I'm aware of with using C#, it's more about preference then about functionality.
Theres one big advantage, you won't have to use Java.
It's not Java, it's a language that is quite similar to C# in structure but have a syntax that is quite similar to Javascript.
C#
float myValue = 5;
Unity Javascript:
var myValue : float = 5;
C#
int MyMethod(float arg)
{ ... }
Unity Javascript:
function MyMethod(var arg : float) : int
{ ... }
Question, need some help...
Say there's a room in my game and the player can dismantle said room and put half of it in his inventory. How could I display what he takes in a menu as a picture of what it did look like before he dismantled it?
Edit: Wondering if there's an easy way to get Unity to screen cap a certain area of screen coordinates.
Question, need some help...
Say there's a room in my game and the player can dismantle said room and put half of it in his inventory. How could I display what he takes in a menu as a picture of what it did look like before he dismantled it?
Edit: Wondering if there's an easy way to get Unity to screen cap a certain area of screen coordinates.
My problem with either Unreal Engine or this is how do i make 3d models? A game will definitly need them Maya is complicated.
I realise that. Its still hideous as hideous as Java.
If you render with 3D-geometry or GUITexture/GUIText that is definitely possible. It you use OnGUI it's not possible (which is very annoying for many reasons).
You can set the target texture for a camera to be a RenderTexture. Then you can read out the pixels to a normal Texture2D. Pro only though.
Been using Unity professionally for 4 years so I can answer questions, if people have any.
Oh good. Which scripting language is easier to learn? Javascript or C#?
Yeah that would be perfect. I have Pro so all things should be a go then!
What I'd like to know is which is BETTER to use in Unity (if there's a difference)
The fact that almost every tutorial I see use C# makes me think that there would be a reason not to use JavaScript.