• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

GAF Learns - Unity [Game Engine]

Anustart

Member
So, do you need to self teach yourself C# before you start measing around?

You won't be able to accomplish much at all without being able to code. Note that it doesn't need to be C# as Unity also works with javascript and Boo.

You can get some sweet falling cubes without code though!
 

Lautaro

Member
You won't be able to accomplish much at all without being able to code. Note that it doesn't need to be C# as Unity also works with javascript and Boo.

You can get some sweet falling cubes without code though!

There's a lot of free code in the web like character controllers, you can still do some nice things without your own code.
 

Anustart

Member
There's a lot of free code in the web like character controllers, you can still do some nice things without your own code.

True. I meant it as more of you're going to have a hard if not impossible time trying to get an idea up and running. A lot of general stuff can be accomplished as you said.

I'd say though definitely learn alongside Unity. No better way to learn how to program then out of necessity and trying to get stuff to work.
 
I have a question. is it possible in unity to lock the amount of input reads (i guess to explain. 60 input frames per second while the game runs at 30 fps?) Does that make any sense and if so, is it possible?
 
I have a question. is it possible in unity to lock the amount of input reads (i guess to explain. 60 input frames per second while the game runs at 30 fps?) Does that make any sense and if so, is it possible?

You could set the Application.targetFrameRate to 30 or 60.

Or do it yourself:

time += Time.deltaTime;

if( time > 1f/60f) // or 30
{
time = 0;
// Process input
}

Unity will poll hardware every frame as far as im aware. But why would you not want it to?
 

Horp

Member
You could set the Application.targetFrameRate to 30 or 60.

Or do it yourself:

time += Time.deltaTime;

if( time > 1f/60f) // or 30
{
time = 0;
// Process input
}

Unity will poll hardware every frame as far as im aware. But why would you not want it to?

That won't achieve what he wants to do. If I understand it correctly he wants to have an internal framerate for input and logic locked at 60, and have the Camera render at 30.
I haven't tried it myself but that should be easily achievable by locking framerate to 60 then Turn Off or On the camera (enabled = false/true) every other frame. For example, in a behaviour on the Camera, do enabled = !enabled in the Update-method.
If you have no other cameras, that should achieve what you want.
 
That won't achieve what he wants to do. If I understand it correctly he wants to have an internal framerate for input and logic locked at 60, and have the Camera render at 30.
I haven't tried it myself but that should be easily achievable by locking framerate to 60 then Turn Off or On the camera (enabled = false/true) every other frame. For example, in a behaviour on the Camera, do enabled = !enabled in the Update-method.
If you have no other cameras, that should achieve what you want.

Im curious as to why he wants this though :S

The camera toggling seems awfully hacky
 

z0m3le

Banned
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.

There is no difference in functionality that I'm aware of, it's a personal opinion you are asking for. Also I wouldn't recommend this to a professional, but as a hobby project, you can mix and match code, if you are doing something in javascript, you can do something else in C# and the engine will understand both without problems, it's not something I think anyone would recommend on a professional level but considering this is about making games for beginners/intermediate level, I don't think anyone should limit themselves to try and learn something that they are uncomfortable with, the reality is that learning one object oriented language will make learning the other language so easy that it's a non issue.

Again visual coding like playmaker is an amazing tool and is top on unity's paid assets for a reason, it allows you to code through menus, knowing how to script will be important, but it can be learned, playmaker however has a lot of helpful points, such as turning your "code" into a flow chart, making it very easy to find issues with your game while also being able to more easily keep track of everything and ultimately shave down the time required to make a game drastically. I think it should be used as a tool for most indie developers just because of it's benefits. We aren't here to code after all, we are here to make games.

I don't think it's wrong to love coding or to even take sides on which language is best, but I think we can easily miss the point and go off topic if we focus on individual languages. Unity is a great engine and it's best feature is it's asset store, just look through it, there is daily sales and a lot of free stuff too, if you don't know how to do something or don't want to waste the time on one common tool, likelihood is someone else has already done it and some of the time its free but even when it's not, I've found the prices reasonable.

Im curious as to why he wants this though :S

The camera toggling seems awfully hacky

It's so input will be flawless even if the game has framerate issues. Doesn't earlier Forza titles do this? Have 60frame input with 30fps render targets?
 

Horp

Member
There is no difference in functionality that I'm aware of, it's a personal opinion you are asking for.

Not really. There is no raw functional difference in how the language can interact with the engine, but there is a huge difference in available documentation and general industrywide usability of C# knowledge compared to UnityJavascript knowledge.

Thats not personal opinion, that's hard facts; one of the languages will be more useful you in your project right away, as well as more useful for you to learn in the long run.
 

z0m3le

Banned
Not really. There is no raw functional difference in how the language can interact with the engine, but there is a huge difference in available documentation and general industrywide usability of C# knowledge compared to UnityJavascript knowledge.

Thats not personal opinion, that's hard facts; one of the languages will be more useful you in your project right away, as well as more useful for you to learn in the long run.

I'm not here to argue about which language is better, you are more knowledgeable than me, however I've never been told of any one thing that C# can do that Javascript can't. I am not trying to tell people who have no preference to learn Javascript, just that if they already know Javascript and aren't using Unity because they don't know C#, that they are being silly and putting up an obstacle for no reason, I think you'd also agree that learning either language makes it far easier to learn the other, so later down the road when they run into an obstacle and they need help and find help in the form of another language, they can probably figure it out thanks to knowing the other.

My posts are only to remove the idea that you need to use C# to make a game, especially for someone who isn't an advanced coder, who shouldn't have these questions anyways as they would almost certainly be very comfortable with one of these languages.

The beauty of a hobby project that one would ideally make who is using this thread as advice, would benefit from just starting with whatever they are comfortable with, and Unity is flexible enough to grow with them even in the same project in case one decides to mix code. That is my point, if you have an example of something functionally that C# does that Javascript can't, be my guest and point that out but as to your point about documentation or finding help online, that really isn't something I'm arguing with you on, I agree C# is the language of choice for many professional developers and it's quite obvious that it would be very well documented as such.
 

Horp

Member
I'm not here to argue about which language is better, you are more knowledgeable than me, however I've never been told of any one thing that C# can do that Javascript can't. I am not trying to tell people who have no preference to learn Javascript, just that if they already know Javascript and aren't using Unity because they don't know C#, that they are being silly and putting up an obstacle for no reason, I think you'd also agree that learning either language makes it far easier to learn the other, so later down the road when they run into an obstacle and they need help and find help in the form of another language, they can probably figure it out thanks to knowing the other.

My posts are only to remove the idea that you need to use C# to make a game, especially for someone who isn't an advanced coder, who shouldn't have these questions anyways as they would almost certainly be very comfortable with one of these languages.

The beauty of a hobby project that one would ideally make who is using this thread as advice, would benefit from just starting with whatever they are comfortable with, and Unity is flexible enough to grow with them even in the same project in case one decides to mix code. That is my point, if you have an example of something functionally that C# does that Javascript can't, be my guest and point that out but as to your point about documentation or finding help online, that really isn't something I'm arguing with you on, I agree C# is the language of choice for many professional developers and it's quite obvious that it would be very well documented as such.

The thing is, if you know Javascript and want to start with Unity the jump from Unity to UnityJavascript is only very slightly smaller than the jump to C#. Unity Javascript isn't the Javascript you find on the web. Especially these days, when Javascript almost always means jQuery in one way or another. Javascript in Unity is just C# with a bit different syntax.

The differences pretty much boil down to:

var VARIABLENAME : type
instead of
type VARIABLENAME

and
function FUNCTIONNAME(args) : returntype
instead of
returntype FUNCTIONNAME(args)

and the fact that a .js file in Unity won't need the
"class ScriptName : MonoBehaviour" at the top for MonoBehaviour classes.

Also
yield;
instead of
yield return true;
 

z0m3le

Banned
The thing is, if you know Javascript and want to start with Unity the jump from Unity to UnityJavascript is only very slightly smaller than the jump to C#. Unity Javascript isn't the Javascript you find on the web. Especially these days, when Javascript almost always means jQuery in one way or another. Javascript in Unity is just C# with a bit different syntax.

The differences pretty much boil down to:

var VARIABLENAME : type
instead of
type VARIABLENAME

and
function FUNCTIONNAME(args) : returntype
instead of
returntype FUNCTIONNAME(args)

and the fact that a .js file in Unity won't need the
"class ScriptName : MonoBehaviour" at the top for MonoBehaviour classes.

Also
yield;
instead of
yield return true;

As someone who knew Javascript and started with Unity only 6 months ago, I have to say that I felt more comfortable using the Javascript in Unity than C# in Unity, I'm not a professional, I've only done small indie projects and just coming from my own experience, I feel that you are seeing this from a C# standpoint, coming from that language might make it seem like Javascript in Unity is just as easy to pick up as C# for a Javascript user, lacks the context of not knowing C#, the reality is when I look at C# I only slightly understand it, but looking at javascript in unity is much more comfortable for someone like me.

I think we've started to derail this thread though and we should go back to actually talking about our experiences / answering questions rather than dealing with which language is better.

To those reading this debate, it doesn't matter what you start with, the point is that you start.
 

Horp

Member
As someone who knew Javascript and started with Unity only 6 months ago, I have to say that I felt more comfortable using the Javascript in Unity than C# in Unity, I'm not a professional, I've only done small indie projects and just coming from my own experience, I feel that you are seeing this from a C# standpoint, coming from that language might make it seem like Javascript in Unity is just as easy to pick up as C# for a Javascript user, lacks the context of not knowing C#, the reality is when I look at C# I only slightly understand it, but looking at javascript in unity is much more comfortable for someone like me.

I think we've started to derail this thread though and we should go back to actually talking about our experiences / answering questions rather than dealing with which language is better.

To those reading this debate, it doesn't matter what you start with, the point is that you start.

Well I can't understand that. They are so similar that I would think that anyone that can understand one well only has to spend a few hours to understand the other just as well. I've converted countless scriptfiles from js to cs in Unity and the process is straight forward enough that it can almost, almost be automated. Let's leave that topic and get back to discussing Unity.

Tip of the day:

If you have Unity pro and want your objects (like characters) to look nicer but don't (or can't) work with Maya/Max, a good suggestion is to bake Ambient occlusion into the models using Unity.

If you fully lightbake your object (using a directional light, like a sun), you wont be able to move it around and rotate it in the game without things looking weird; but just baking ambient occlusion will keep the object dynamic.

This picture of my beautiful 4-cubes-tank illustrates what kind of effect the baked ambient occlusion has. Note that this object still recieves dynamic light (from point lights for example).
bakedAmbientOcclusion.jpg


To do this follow these steps:
1. Make the object lightmap static. Click the small arrow beside "Static" in inspector and select lightmap static.

2. Open Lightmapper. Go into "Bake". Increase "Ambient Occlusion" to a pretty high value. Make sure no lights are enabled (or make sure those lights are realtime-only).

3. Increase Sky Light Intensity to 0.8 or something (this can be tweaked). You might want to change Sky Light color to White. (or a color that suits your overall scene).

4. Click bake. Wait.

5. You might have to lower the brightness of the material that is on your baked object.

(PS. Make sure you almost always have lights enabled in the Scene view! DS).
 

Arkadios

Member
My problem with either Unreal Engine or this is how do i make 3d models? A game will definitly need them :D Maya is complicated.

There are tons of tutorials about 3D packages around the internet. Eat 3D, Gnomon Workshop, CG Tuts+, etc. If you're new to modelling looking for "Getting started with..." type-videos may help presenting you the UI.
 

z0m3le

Banned
How good is unity at rendering nature scenes and open world environments?

Here is an example of an environment asset on the Unity Asset Store. It just depends on how much time you want to spend on it, there is also 3rd party tools to create your own scenes outside of Unity that make things a bit easier and faster to do such as AGF.
 

Lautaro

Member
I'm working in an Android project but I would like to create an iOS version too. The problem is that I need to buy a Mac for that, so... can I go for a cheap one? anything I should know? (I have no idea about Mac's)
 

EVIL

Member
How good is unity at rendering nature scenes and open world environments?

You can do some cool shit but it all boils down to the artist and how much time he/she invests. I mean there where not allot of great examples of realistic nature environments on the source engine, but then came the dude that did the environments for dear ester and bam!, it unleashed all that potential.
 
Ughh whenever I open up Unity I just stare at the blank screen like a dumbass and get depressed. Farthest I've ever gotten was that I made a third person car out of some cubes and spheres (and some awful c# lol )
 

Lautaro

Member
Ughh whenever I open up Unity I just stare at the blank screen like a dumbass and get depressed. Farthest I've ever gotten was that I made a third person car out of some cubes and spheres (and some awful c# lol )

If the problem is knowledge of the engine, just make tutorials until you get the hang of it (Lerpz's 3d platformer and the FPS tutorials helped me greatly), also some books like Game Development Essentials.

If the problem is not knowing what to do, you could try to join a project in the official forums.

Now, if the problem is lazyness or inability to focus, then I'll probably won't be able to help you because I suffer it too (making a list of things to do helps though).
 
Question, I'm trying to script where you press specific buttons with mouse to change the scene. How do I do this?

For example, if I pressed #1,2,3, and 4, it changes the scene.
 

Lautaro

Member
Question, I'm trying to script where you press specific buttons with mouse to change the scene. How do I do this?

For example, if I pressed #1,2,3, and 4, it changes the scene.

You mean when you press a specific number or a GUI button?

If is numbers, you can put this in the Update method of a script (C#):

if(Input.GetKey(KeyCode.Alpha1)){
Application.LoadLevel("level_name");
}

This will load a scene with a specific name if you press "1" (in the alphanumeric kb).

If is a GUI button, something like this (in the OnGUI method):

if(GUI.Button(new Rect(0, 0, 100.0f, 100.0f), "Text")){
Application.LoadLevel("level_name");
}

Two things:

- The scene needs to be added in the Build Settings (File -> Build Settings).
- When the scene is loaded the object that contains this script will be destroyed unless you use DontDestroyOnLoad or you can have a similar object with the same script running in the loaded scene.
 

Horp

Member
Ughh whenever I open up Unity I just stare at the blank screen like a dumbass and get depressed. Farthest I've ever gotten was that I made a third person car out of some cubes and spheres (and some awful c# lol )

My suggestion is to start by coming up with some really, really basic idea of a game. Something like "A game where you click boxes that shows up on the screen, and the boxes becomes smaller and smaller and come up faster and faster". Then, when you have picked your idea, keep trying and working until you finish. Starting from a blank space is always daunting and can get depressing.
 
You mean when you press a specific number or a GUI button?

If is numbers, you can put this in the Update method of a script (C#):

if(Input.GetKey(KeyCode.Alpha1)){
Application.LoadLevel("level_name");
}

This will load a scene with a specific name if you press "1" (in the alphanumeric kb).

If is a GUI button, something like this (in the OnGUI method):

if(GUI.Button(new Rect(0, 0, 100.0f, 100.0f), "Text")){
Application.LoadLevel("level_name");
}

Two things:

- The scene needs to be added in the Build Settings (File -> Build Settings).
- When the scene is loaded the object that contains this script will be destroyed unless you use DontDestroyOnLoad or you can have a similar object with the same script running in the loaded scene.
Thanks, but it's not GUI. Maybe I should've specified.

For example, let's say you are trying to script an electronic lock? The one that has numbers. If you press buttons "1,5,2,7" on the keypad it will unlock the door.

I'm trying to do something similar to that with gameobjects using mouse button.
 

Margalis

Banned
Ughh whenever I open up Unity I just stare at the blank screen like a dumbass and get depressed. Farthest I've ever gotten was that I made a third person car out of some cubes and spheres (and some awful c# lol )

Making a game is all about just putting one foot in front of the other.

At the start of a project it can seem like an insurmountable amount of work. Near the end of a project it can still feel that way. If you stop and think about how much work there is to do it always feels like too much, but if you chip away eventually something will get made.
 
Thanks, but it's not GUI. Maybe I should've specified.

For example, let's say you are trying to script an electronic lock? The one that has numbers. If you press buttons "1,5,2,7" on the keypad it will unlock the door.

I'm trying to do something similar to that with gameobjects using mouse button.

Unity's GUI system sucks, so I use a second camera with the background clear flag (so the background color doesn't get rendered), then use that to render GUI objects over the main gameplay camera. Then you can use actual 3d objects as GUI objects.

Each button on your keypad could have a box collider on it with a different tag or script component to differentiate each button from one another.

On mouse up, use the Camera.ScreenPointToRay to do a raycast from the GUI camera to see if / what you hit.
 
I've dabbled with code quite a bit before (Java, C#) but I've never made anything 3D. I saw this thread shortly after it was created and it inspired me to try learning a bit of Unity. I just completed the first rolling ball tutorial and it was very fun! I'm going to make the only other example project (stealth game) later when I find time.
 

Rich!

Member
Is unity well suited for 2D games? I'm working on a game right now and I've heard good things about Unity.

Wii U support sounds interesting too.

For reference, I designed a top down Zelda clone in Shockwav and I'm trying to work further on it but shockwave is frustratingly limited.
 

Lautaro

Member
Is unity well suited for 2D games? I'm working on a game right now and I've heard good things about Unity.

Wii U support sounds interesting too.

For reference, I designed a top down Zelda clone in Shockwav and I'm trying to work further on it but shockwave is frustratingly limited.

I haven't tested the new 2D tools but apparently they are pretty good. A post in this thread has a link to a tutorial.
 
I think it works fine for 2D games. I just made a top-down game for Ludum Dare with it and didn't really have problems related to it being 2D within a 3D engine. It's possible that some things are simpler to do within an engine purely suited to 2D games, though as you've mentioned, with those you're often limited in what you can do in other ways.
 

Maybesew

Member
My wife and I have been looking to create a minesweeper type game, and I figured 2D Unity would be a good place to start.

Is there any reason this is overkill? We are basically just doing it as a learning exercise and something we can do together.
 
My wife and I have been looking to create a minesweeper type game, and I figured 2D Unity would be a good place to start.

Is there any reason this is overkill? We are basically just doing it as a learning exercise and something we can do together.

Well, it depends on your goal. If you're going to use this as a learning experience then move on to more complex types of games using Unity, sure, that sounds like a good plan.

On the other hand, if you don't particularly care about Unity or are just looking for the simplest way to make a Minesweeper game, I'd say it's definitely overkill. For a game that's basically just a bunch of standard buttons, a .NET form would work just fine for instance (or even an HTML/Javascript file if you don't care about persisting any data). Though I've never used it, I'd assume Game Maker could also make that sort of thing in a simpler way than Unity.
 

Dramos

Member
Oh good. Which scripting language is easier to learn? Javascript or C#?

Their quite different. C# is a stricly typed language meaning and Javascript is a loosely typed language. There's more variety for the stuff you can do with C# (back and front end work) but Javascript is mostly very handy for web development. You can use both to code games although MS dropped its XNA framework but there are still some similar 3rd party frameworks like Monogame.
 

BibiMaghoo

Member
Oh good. Which scripting language is easier to learn? Javascript or C#?

I would say Java, but neither is really what is used, as both are Unity script based on one or the other. If you know one or the other, you will still need to learn how Unity calls certain functions etc. It's axis are also different from the norm.

These are things you pick up as you go, but I would say Java based Unity script is easier.
 

Horp

Member
I would say Java, but neither is really what is used, as both are Unity script based on one or the other. If you know one or the other, you will still need to learn how Unity calls certain functions etc. It's axis are also different from the norm.

These are things you pick up as you go, but I would say Java based Unity script is easier.

There is no Java in Unity. There is a scripting language that is slightly similar to Javascript called UnityScript, but there are many strong arguments for using C# instead of UnityScript. Read my earlier posts in this thread for some of them.
 

BibiMaghoo

Member
There is no Java in Unity. There is a scripting language that is slightly similar to Javascript called UnityScript, but there are many strong arguments for using C# instead of UnityScript. Read my earlier posts in this thread for some of them.

That is like literally, what I said in my post lol. That the Java in use is Unity script. I'm not sure how you could quote me then tell me again what you quoted :D

I would recommend J based US for ease over C#, from my own experiences, as being slightly less maddening, not because it is in any way 'better'.
 

BibiMaghoo

Member
The issue I think he's taking with your post is that you say Java instead of JavaScript, which are two different languages.

Ah, my mistake then. I was scratching my head trying to understand. My apologies Horp. I'm still in the process of learning scripting at all - currently trying with great frustration to implement pathfinding with non-pro, without downloading a package and just sticking it in the game.

But yes, I see the distinction.
 

Lhadatt

Member
That is like literally, what I said in my post lol. That the Java in use is Unity script. I'm not sure how you could quote me then tell me again what you quoted :D
Java is not JavaScript. They are entirely different things. EDIT -- beaten by Wuncler.

I would recommend J based US for ease over C#, from my own experiences, as being slightly less maddening, not because it is in any way 'better'.
The way I see it, if you lean toward web tech and client-side stuff in browsers (AJAX, for example) or simpler server-side stuff (Node.js), concentrate on Javascript. If you want to do more complex server-side programming, .NET/Mono development, or have more of a C-orientated background, use C#. Or use Boo if you want to be contrarian. You can certainly use some combination of any/all of them if you can keep track of different languages or find certain things easier to do in one over another (this is possibly bad form though, if working in a group).

Unity offers another option -- compiling code in other languages to DLLs using external editors (i.e. Visual Studio) and importing those DLLs into the editor. This is probably more advanced than what we need in this thread, but it's an option.
http://docs.unity3d.com/Documentation/Manual/UsingDLL.html
 
I have unity downloading and studying C# seems to fit it, but I would like to do as much myself as I can so is there any tutorial for Doing game from scrach in C++ for example? My goal is to make sprite charachter to show on level. Maybe make it even jump. I think it would be great project at side of university studies and unity. Edit: Using visualstudio 2013 ultimate.
Edit2: What is best language to learn. I get C# from uni, but when specialising to game dev I think i am gooing to take some other language as side study. Java any good. Sorry for off-topic but unity is still downloading.
 

Lhadatt

Member
I have unity downloading and studying C# seems to fit it, but I would like to do as much myself as I can so is there any tutorial for Doing game from scrach in C++ for example? My goal is to make sprite charachter to show on level. Maybe make it even jump. I think it would be great project at side of university studies and unity. Edit: Using visualstudio 2013 ultimate.
Edit2: What is best language to learn. I get C# from uni, but when specialising to game dev I think i am gooing to take some other language as side study. Java any good. Sorry for off-topic but unity is still downloading.

C# is a good language to start Unity with, especially if you're already immersed in it. Check out this tutorial for 2D game design. It covers creating a shmup in Unity using 2D sprites, movement, projectiles, collision, background and parallax scrolling, and a few other topics.

http://pixelnest.io/tutorials/2d-game-unity/

Don't take their bit about using Visual Studio for C# development too seriously. That's their opinion and they can have it, but I haven't had any issues following their tutorial using MonoDevelop. Don't make things complicated unless you're comfortable dealing with the self-imposed complexity. :)

Also take a look at their other tutorials, they have some interesting articles.
 
C# is a good language to start Unity with, especially if you're already immersed in it. Check out this tutorial for 2D game design. It covers creating a shmup in Unity using 2D sprites, movement, projectiles, collision, background and parallax scrolling, and a few other topics.

http://pixelnest.io/tutorials/2d-game-unity/

Don't take their bit about using Visual Studio for C# development too seriously. That's their opinion and they can have it, but I haven't had any issues following their tutorial using MonoDevelop. Don't make things complicated unless you're comfortable dealing with the self-imposed complexity. :)

Also take a look at their other tutorials, they have some interesting articles.

Thanks. Will try. I just want to make square to jump on level/platform and do it from scrach for experimental reasons. I know there is lot of time to do these when i have more experience but I would be more thrilled to make square jump using only visualstudio than make a game on unity. It just sounds more cool and gives bragging rights :) I am going to try unity now.
 
Top Bottom