• 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]

Horp

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

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

I saw your post after your post on the last page. Glad you got it. And C# is objectively better in Unity for several reasons.
 
question, I am looking at the asset store, and I see models, systems, etc on sale, some pretty cheap? You can just buy these to use in your project?

Whats the catch? I spend $50 bucks and get a bunch of assets I can reuse in my own game? That just seems too good to be true...
 

Lautaro

Member
question, I am looking at the asset store, and I see models, systems, etc on sale, some pretty cheap? You can just buy these to use in your project?

Whats the catch? I spend $50 bucks and get a bunch of assets I can reuse in my own game? That just seems too good to be true...

Welcome to Unity.

Well, there's some assets that require a license per seat but most of them can be used in any project. They are covered by the same license of the engine so they can be used for commercial projects as long as it's a Unity project, I think.

Here's the EULA for more information: http://unity3d.com/company/legal/as_terms
 

Hari Seldon

Member
So I have finally bit the bullet and decided to jump in with both feet into Unity. My buddy found a very new tutorial which is slow but I rather like because it gives me insight to the workflow.

http://www.youtube.com/watch?v=sfqC...ipikZfYTAwiHsXl11xCI6s&feature=c4-overview-vl

I have a couple questions though. Monodevelop is driving me fucking crazy with the weird god damn way it fucks around with the { }. Also it keeps adding spaces between my function name and the (). Is there a way to configure this thing to be less annoying?

Regarding DLLs, so theoretically I could compile old school C and use those in my project? I have never used C# with C DLLs before so I don't even know if this is possible haha.
 

Lautaro

Member
So I have finally bit the bullet and decided to jump in with both feet into Unity. My buddy found a very new tutorial which is slow but I rather like because it gives me insight to the workflow.

http://www.youtube.com/watch?v=sfqC...ipikZfYTAwiHsXl11xCI6s&feature=c4-overview-vl

I have a couple questions though. Monodevelop is driving me fucking crazy with the weird god damn way it fucks around with the { }. Also it keeps adding spaces between my function name and the (). Is there a way to configure this thing to be less annoying?

Regarding DLLs, so theoretically I could compile old school C and use those in my project? I have never used C# with C DLLs before so I don't even know if this is possible haha.

I just get used to MonoDevelop's quirks but maybe you could try using Visual Studio: http://docs.unity3d.com/Documentation/Manual/VisualStudioIntegration.html

DLL files in Unity are known as plugins and can be used only in Unity Pro, using C# with a C++ dll is no different from using .NET with any other dll, remember that Unity uses Mono that is basically .NET.
 
I have a couple questions though. Monodevelop is driving me fucking crazy with the weird god damn way it fucks around with the { }. Also it keeps adding spaces between my function name and the (). Is there a way to configure this thing to be less annoying?

Go into the "project" menu, select "solution options", then under "code formatting" you can select a different policy for each file type, or override the settings manually.

I know, the default formatting settings are horrible. :|
 

Water

Member
So I have finally bit the bullet and decided to jump in with both feet into Unity. My buddy found a very new tutorial which is slow but I rather like because it gives me insight to the workflow.

http://www.youtube.com/watch?v=sfqC...ipikZfYTAwiHsXl11xCI6s&feature=c4-overview-vl

I have a couple questions though. Monodevelop is driving me fucking crazy with the weird god damn way it fucks around with the { }. Also it keeps adding spaces between my function name and the (). Is there a way to configure this thing to be less annoying?
I went to the settings for C# editing and found a number of settings for these. MonoDevelop still adds in some spaces I don't want, but much less.
I think I'm gonna try to switch to Visual Studio for the project I'm starting now.
 

Water

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.
Given your particular situation, I'd specifically recommend against Java. It's not used much at all in game development, and C# is very much like Java so you aren't going to learn anything significantly different.

I'd generally recommend just doubling down on C# and coding harder things instead of trying to dabble a little bit in different languages. If you must add on another language, C++ would definitely fit the "do everything yourself" bill. It has to be said, though, that getting good enough with C++ that it's worth using for any serious project takes a long time.
 

Bedlam

Member
Hey UnityGAF!

I have a question regarding the organization of my texture files and draw calls. First off, the game I'm making together with a friend (we started on XNA some time ago but recently decided to switch to Unity) is an top-down game similar to Diablo as far as the visuals go (top-down, isometric view). Due to its setting, it features a lot of transparent branches, plants, grass and so on. Right now I have 4 texture files for tree branches (with 3,4 branches contained in each file), 4 texture files for grass models and a couple more for plants. I'm thinking that maybe combining these files into one for each (branches, grass, plants) is the way to go to reduce draw calls but it would involve some work with retexturing the existing models in blender. Is it worth it? I should say that trees, plants and grass models are pretty much always part of the scene during the gameplay.
 
Hey UnityGAF!

I have a question regarding the organization of my texture files and draw calls. First off, the game I'm making together with a friend (we started on XNA some time ago but recently decided to switch to Unity) is an top-down game similar to Diablo as far as the visuals go (top-down, isometric view). Due to its setting, it features a lot of transparent branches, plants, grass and so on. Right now I have 4 texture files for tree branches (with 3,4 branches contained in each file), 4 texture files for grass models and a couple more for plants. I'm thinking that maybe combining these files into one for each (branches, grass, plants) is the way to go to reduce draw calls but it would involve some work with retexturing the existing models in blender. Is it worth it? I should say that trees, plants and grass models are pretty much always part of the scene during the gameplay.

You could and should atlas every texture onto one gigantic texture atlas. Itll piss your artist off but its something he should be doing anyway. If all your game assets share the same texture/materials it will dynamically batch all of them (assuming it meets the criteria for batching)
 

RoadHazard

Gold Member
I've just started using Unity, and it's pretty sweet! I have a lot of programming experience from university, so the scripting part of it is no problem, and it's really pretty amazing how easy Unity makes connecting everything together to make it work. There are still things I need to learn, of course, but I feel like I have to basics down pretty well.

Currently using the free version. I didn't want to do the 30-day pro trial, because I knew it would be really annoying to have started a project using those features and then not be able to use them anymore. So I'd rather just limit myself to what the free version can do right from the start. With that in mind, what is a sensible approach to doing some simple pathfinding AI with the free version, given that those features are only in the pro version? Would the free version of this be a decent solution? Don't really want to pay for anything right now.
 

Bedlam

Member
You could and should atlas every texture onto one gigantic texture atlas. Itll piss your artist off but its something he should be doing anyway. If all your game assets share the same texture/materials it will dynamically batch all of them (assuming it meets the criteria for batching)
Okay, thanks. I am our artist btw. And a noob also. ;)

Is this something that should be done as early as possible in the development cycle (and then continually be extended) or should it be done preferably once all the textures used in the game actually exist?

Let's say I don't want to use mip-mapping for certain single textures because -reasons-, does that mean I would've to use at least two texture atlases? One with the regular textures and one with the textures I want in Unity without mipmaps? Or is that something that one would strongly advise against? As for the reasons: I've experimented a bit with my transparent grass textures, branches and so on and they just look atrocious when mipmapped to smaller resolutions. I'd preferably keep those textures "raw" even if it means more ram usage. It's not like our game will be that demanding anyway on the ram front.
 
Okay, thanks. I am our artist btw. And a noob also. ;)

Is this something that should be done as early as possible in the development cycle (and then continually be extended) or should it be done preferably once all the textures used in the game actually exist?

Let's say I don't want to use mip-mapping for certain single textures because -reasons-, does that mean I would've to use at least two texture atlases? One with the regular textures and one with the textures I want in Unity without mipmaps? Or is that something that one would strongly advise against? As for the reasons: I've experimented a bit with my transparent grass textures, branches and so on and they just look atrocious when mipmapped to smaller resolutions. I'd preferably keep those textures "raw" even if it means more ram usage. It's not like our game will be that demanding anyway on the ram front.

We just add to the atlas as we go. As the grass is going to use transparency you may as well use that as a separate texture or a make a transparency atlas.

The transparent textures in our game are all separate textures but they're very small.
 

RoadHazard

Gold Member
Been messing around with A* Pathfinding Project, a pretty awesome tool for getting some pathfinding up and running (since none is included in the free version of Unity). Very easy to use, and the results are pretty cool. Here's a little GIF of a test scene I made:

i7Xkh7A908k2a.gif


The scene is scanned by the tool to create a grid of walkable and non-walkable areas, and then I basically just tell each little "guy" (which I continuously spawn at the red dome) to find his way to the target location at the center of the green dome. That they don't all take the optimal route is intentional - by default they do, but you can add a penalty to taking a path that has already been taken to make the pathfinding behavior a little more random and fun.

What the tool shows in the editor while the "game" is running:

irimwK7c029WJ.PNG


Haven't done anything real with this yet, but from seeing what it can do with so little effort I think it could be used for some cool stuff.
 

RoadHazard

Gold Member
I'm sure third party stuff has more functionality, but Unity's built-in navmesh baking has been free since 4.2. Only some advanced pathfinding features need Pro anymore.

Hmm, really? I was under the impression that what's included in the free version is rather limiting. Also, is it only navmesh pathfinding? That's not bad per se, of course, but the scanned pathfinding grids you can create with the above tool are hella convenient. It takes basically no time to create a good pathfinding grid for a scene, and then it's just a few lines of scripting to make your AI characters navigate it.

Fake edit: Just looked into this, and it seems like the navmesh agents, which are what you use to do any actual pathfinding, are exclusive to the pro version. So that means that you'll still need to use third-party tools for this, or code it yourself I guess. And given that the "agents" provided by the A* Pathfinding Project are so easy to use, that still seems like a good choice to me.
 

Water

Member
Fake edit: Just looked into this, and it seems like the navmesh agents, which are what you use to do any actual pathfinding, are exclusive to the pro version.
No, navmesh agents are not exclusive. They went free at the same time as navmesh baking; otherwise what would be the point of baking navmeshes in the free version?
 

RoadHazard

Gold Member
No, navmesh agents are not exclusive. They went free at the same time as navmesh baking; otherwise what would be the point of baking navmeshes in the free version?

Huh, a ton of official Unity documentation says they are pro only. But if that's not the case, that's great! Definitely gonna check those out as well then, and see what is actually nicest to work with.

EDIT: Ok, you're right, and yeah, those are also almost stupidly easy to use!
 
I'm doing a project for my university - in which I'm trying to incorporate a NPC who is giving instructions to player through intercomm so I need to display a talking head over the scene.

Is it possible to have something like picture in picture where main camera has focus on main scene and in one of screen corners there's a view from second camera ?
 

Vintage

Member
I just get used to MonoDevelop's quirks but maybe you could try using Visual Studio: http://docs.unity3d.com/Documentation/Manual/VisualStudioIntegration.html

Does debugging work on VS pro and is it stable?

I've tried creating something in Unity several times, but each time I was put off by terrible, terrible stability. Unity editor kept hanging and crashing like every 15 minutes, Monodevelop refused to show variables or current line being stepped over, UI elements randomly became unresponsive to the point of being completely unusable. Debugger always fails to attach, have to restart editor for every launch. One time after a crash my entire project was empty! The assets obviously were still there, but all the objects inside a scene together with their positions and properties were gone (3 hours of work at least).

I can't imagine how they expect to become a AAA engine when their tools are completely broken.
 

RoadHazard

Gold Member
Does debugging work on VS pro and is it stable?

I've tried creating something in Unity several times, but each time I was put off by terrible, terrible stability. Unity editor kept hanging and crashing like every 15 minutes, Monodevelop refused to show variables or current line being stepped over, UI elements randomly became unresponsive to the point of being completely unusable. Debugger always fails to attach, have to restart editor for every launch. One time after a crash my entire project was empty! The assets obviously were still there, but all the objects inside a scene together with their positions and properties were gone (3 hours of work at least).

I can't imagine how they expect to become a AAA engine when their tools are completely broken.

Beyond MonoDevelop sometimes being a bit annoying I haven't really had any of those issues. Granted, I haven't made anything particularly large yet, but it sounds like you haven't either.
 
Anyone have any tips or best practices for setting up your object model within unity properly? Ie do I use a singleton or what? Where should the main game class for my game reside ideally? I had the basics of Unity down in the summer but stopped due to other work when I was beginning to research this question.
 
Does debugging work on VS pro and is it stable?

I've tried creating something in Unity several times, but each time I was put off by terrible, terrible stability. Unity editor kept hanging and crashing like every 15 minutes, Monodevelop refused to show variables or current line being stepped over, UI elements randomly became unresponsive to the point of being completely unusable. Debugger always fails to attach, have to restart editor for every launch. One time after a crash my entire project was empty! The assets obviously were still there, but all the objects inside a scene together with their positions and properties were gone (3 hours of work at least).

I can't imagine how they expect to become a AAA engine when their tools are completely broken.

Huh. I've used Unity every now and then for a couple of years now (including one bigger project for a game development course) and I've never had any issues with its stability. The only frustrating thing I remember is ctrl+P (shortcut to play mode in Unity) making MonoDevelop hang for a while because I don't have printers, but that's my own problem and I think they've now even removed that shortcut. Oh and of course it would be great if it was easier to use Sublime Text with Unity, but that's something I'll just have to live with.

I wish I had the time (and ideas) to start doing Unity stuff again :(

Anyone have any tips or best practices for setting up your object model within unity properly? Ie do I use a singleton or what? Where should the main game class for my game reside ideally? I had the basics of Unity down in the summer but stopped due to other work when I was beginning to research this question.
What kind of things would this main game class do? You may have a good reason to have something like that, but you may also be thinking of it in a wrong way. Unity is very much based on the interactions of separate objects which define their own behaviour, without any need for an overseeing third party (except the engine itself, of course).
 

Griss

Member
Hi UnityGAF. I've 'learned' Unity twice now, and had plenty of fun messing around creating simple playgrounds full of physics and win conditions before quitting due to work/time issues. I came from a C++ background originally so C#'s pretty much a breeze once I get over my rustiness at coding.

Now what I'd like to do is prototype a menu-heavy RPG. What I'm really interested in is prototyping a battle system, and being able to quickly tweak the parameters of the party members and enemies to see what works and what doesn't in terms of turn-based gameplay. I like tinkering with numbers, and Unity is a great way to set something like that up quickly as you can adjust things on the fly.

A couple of questions:
1. Any recommendations for UI plugins from the Asset store? There's a lot there, it's overwhelming. I'd like something quick and simple to set up, with no baked-in visual theme (fantasy; tech; cutesy etc) if possible. Faffing around with the basic UI has been slower than I'd like. If that's a bad idea, any good UI tutorials about?

2. If you were making an RPG that goes to a separate battle screen for each battle, how would you organize that in terms of separate scenes? My levels will be one scene, with the interiors of houses etc placed out in space in the same scene. But do I need to switch between scenes every time there's a battle? Is that practical? Doesn't seem like it.

3. What's the best way to pass data between scenes? This will be data heavy, and all the party stats etc will need to be available in both scenes, whether that's each new area of the game or transitioning to the battle scene. This is the one place that I've struggled with as tutorials and books I've followed have largely been a menu scene followed by a main scene. I need the same data available throughout the game, but making everything global/static etc seems bizarre to me. Also, any good tutorials on writing to/reading from save files?

It's just a hobby for me but I'd appreciate any help. The one thing that always makes me give up for months at a time is realising that I wish I'd planned out my object hierarchy differently and then despairing when I realise the amount of changes it would take to make that a reality. That and having no art. But after a few months away, I'm back, lol. Any help appreciated.
 

Water

Member
Huh, a ton of official Unity documentation says they are pro only. But if that's not the case, that's great! Definitely gonna check those out as well then, and see what is actually nicest to work with.

EDIT: Ok, you're right, and yeah, those are also almost stupidly easy to use!
Yeah, unfortunately official Unity documentation is bad a lot of the time.
Navmesh and navmesh agents are one example of that. They are indeed stupidly easy to use for simple stuff, but there are some elementary questions the documentation doesn't answer, like how the logic works if agents are instantiated outside the navmesh, what if the set destination is outside the navmesh, etc.
There's also no clear explanation of how navmeshagent functionality interacts with rigidbody physics. I did a small prototype in Fall where both navigation and non-kinematic physics were needed on the same objects. Still don't know when and how each of those is supposed to override the other, or if it's just undefined/broken, but they certainly don't play well together and we ended up just kind of crossing our fingers, using small hacks and hoping it doesn't explode when both are active at the same time. You'd think Unity would give some guidelines or even build in some settings to make it easier to combine navigation with physics, e.g. the common usecase where things navigate without interference from physics until knocked around/ragdolled/etc. and resume navigation later once they stop bouncing and settle back on the navmesh. Another big piece of functionality that would be helpful is being somehow able to automatically create colliders based on the navmesh such that an agent affected by physics can't bounce entirely outside the navmesh area, and will eventually settle down somewhere back on the navmesh if not bumped again.
 
2. If you were making an RPG that goes to a separate battle screen for each battle, how would you organize that in terms of separate scenes? My levels will be one scene, with the interiors of houses etc placed out in space in the same scene. But do I need to switch between scenes every time there's a battle? Is that practical? Doesn't seem like it.
You have a couple of choices, but no point explaining it here since someone's already done it: http://answers.unity3d.com/questions/581656/classic-turn-based-rpg-battle-scene-question.html

In fact, the great thing about Unity is that the community is huge and someone's already solved the problem you have (or at least tried to solve it). Here's something relevant to your 3rd question: http://answers.unity3d.com/questions/532656/what-is-the-best-way-to-pass-data-between-scenes.html

It's just a hobby for me but I'd appreciate any help. The one thing that always makes me give up for months at a time is realising that I wish I'd planned out my object hierarchy differently and then despairing when I realise the amount of changes it would take to make that a reality. That and having no art. But after a few months away, I'm back, lol. Any help appreciated.
I know what you're talking about since I'm exactly the same, but it's very important to not fall into the overengineering trap. The answer is that you don't really need to refactor your entire codebase to do what you want to do. A finished game with the messiest code of all time is better than an unfinished game with a well thought-out structure.
 

Griss

Member
You have a couple of choices, but no point explaining it here since someone's already done it: http://answers.unity3d.com/questions/581656/classic-turn-based-rpg-battle-scene-question.html

In fact, the great thing about Unity is that the community is huge and someone's already solved the problem you have (or at least tried to solve it). Here's something relevant to your 3rd question: http://answers.unity3d.com/questions/532656/what-is-the-best-way-to-pass-data-between-scenes.html


I know what you're talking about since I'm exactly the same, but it's very important to not fall into the overengineering trap. The answer is that you don't really need to refactor your entire codebase to do what you want to do. A finished game with the messiest code of all time is better than an unfinished game with a well thought-out structure.

Thanks, I don't know how I missed that post as I'm on Unity Answers myself, but it's perfect. Also agree that the key is just to finish something. You learn so much if you just push through to the finish despite mistakes. That's the hard part, finishing.
 
Thanks, I don't know how I missed that post as I'm on Unity Answers myself, but it's perfect. Also agree that the key is just to finish something. You learn so much if you just push through to the finish despite mistakes. That's the hard part, finishing.

Yeah, it sure is. I've been thinking of taking part in a game jam, just to have something done that's then released to the public - game jam games even have an excuse for being crappy! I've had one game idea in my head for a while now, but I've already overdesigned the thing to something I could never create (like wanting to have actual vector based graphics when I could just as well draw lines in Paint to have the same effect...).
 

Yoshi

Headmaster of Console Warrior Jugendstrafanstalt
I'd also like to start learning Unity. My problem will probably arise from graphics, because I can program in Java and C++ without any real problems. For a 3D game I will need models though and I'm not quite confident I'll be able to make them. However, I plan on doing a 3D collectathon platformer, since I'm missing this genre so much. I've already programmed some 2D games in the past (without using an engine), but this will be a serious step up in difficulty I guess. Especially scaling objects properly in 3D depending on their distance and being efficient with what objects to compute (objects that are begind other ones shouldn't be rendered, of course). While I'm still not confident I'll be able to pull this off, a friend of mine and my fiancée are interested in helping me with level and scenario design, so I hope I'll have enough motivation.

However there are two questions I'd like to ask the NeoGAF pros:
1. Can someone recommend a good tutorial for my goal (development of a 3D platformer with Unity)?
2. Although it might not be too likely, if I end up being really happy with the end result, I'd like to play my game on a console (Wii U being the obvious choice?); can I just apply for an Indie-license and in case I get it, compile the game as a Wii U build? What would I need to keep in mind when programming my game to get it running on Wii U (or another console where I'd be able to run the game on more easily, but also cheap)? Finally, would I be able to upload my game to eShop free of charge? Because I don't want to make money with games, I just want to make a game I (and my partners) will enjoy to play and I'd like them to be able to play it on their Wii U too.
 
I'd also like to start learning Unity. My problem will probably arise from graphics, because I can program in Java and C++ without any real problems. For a 3D game I will need models though and I'm not quite confident I'll be able to make them. However, I plan on doing a 3D collectathon platformer, since I'm missing this genre so much. I've already programmed some 2D games in the past (without using an engine), but this will be a serious step up in difficulty I guess. Especially scaling objects properly in 3D depending on their distance and being efficient with what objects to compute (objects that are begind other ones shouldn't be rendered, of course). While I'm still not confident I'll be able to pull this off, a friend of mine and my fiancée are interested in helping me with level and scenario design, so I hope I'll have enough motivation.

However there are two questions I'd like to ask the NeoGAF pros:
1. Can someone recommend a good tutorial for my goal (development of a 3D platformer with Unity)?
Unity is a complete game engine, so they've already taken care of your worries about low-level stuff like rendering objects properly - you can concentrate on building the game itself. Models are of course a logistical problem with 3D games, but you can start developing with placeholder models like boxes/cylinders etc. (can be created directly in Unity) or download something from the Unity asset store - you can find some free ones there, too.

Here's the official tutorial for a 3D platformer, though it seems to be quite out of date so I'm not sure if it works in the newer Unity versions: https://www.assetstore.unity3d.com/#/content/5087
 

RoadHazard

Gold Member
Yeah, unfortunately official Unity documentation is bad a lot of the time.
Navmesh and navmesh agents are one example of that. They are indeed stupidly easy to use for simple stuff, but there are some elementary questions the documentation doesn't answer, like how the logic works if agents are instantiated outside the navmesh, what if the set destination is outside the navmesh, etc.
There's also no clear explanation of how navmeshagent functionality interacts with rigidbody physics. I did a small prototype in Fall where both navigation and non-kinematic physics were needed on the same objects. Still don't know when and how each of those is supposed to override the other, or if it's just undefined/broken, but they certainly don't play well together and we ended up just kind of crossing our fingers, using small hacks and hoping it doesn't explode when both are active at the same time. You'd think Unity would give some guidelines or even build in some settings to make it easier to combine navigation with physics, e.g. the common usecase where things navigate without interference from physics until knocked around/ragdolled/etc. and resume navigation later once they stop bouncing and settle back on the navmesh. Another big piece of functionality that would be helpful is being somehow able to automatically create colliders based on the navmesh such that an agent affected by physics can't bounce entirely outside the navmesh area, and will eventually settle down somewhere back on the navmesh if not bumped again.

Yep, the documentation on this stuff seems pretty bad. Regarding your example, isn't there any way to manually stop the agent from navigating, turn it non-kinematic, apply the appropriate forces, and then turn it kinematic and tell it to start nagivating again? I'm not deep enough into this stuff to be completely aware of the limitations yet.

But hey, now that I was made aware that the free version actually has this stuff (had you not told me I don't know if I would ever have found out, so thanks!) I at least got an improved version of my previous test scene up and running quickly:

pathfinding_navmesh_2thjtg.gif


So yeah, really easy stuff to use! And it can do layered pathfinding, which the 3rd party tool I used before can't unless you manually create navmeshes. There's no automatic navmesh generation in the free version of that, and the pathfinding grids only work in one layer since it just scans the geometry from above. So Unity's built-in stuff is definitely superior there. And the agents are even easier to use as well, at least when it's nothing more complex than simply telling them where to go. The only thing I miss is the "alternate path" stuff from the other tool, where you can make the "seekers" take other paths than the most optimal one to make things more interesting. Can't find a way to easily do that with Unity's built-in tools.
 

RoadHazard

Gold Member
Can anyone with more solid Unity knowledge than me explan why this isn't working?

I'm spawning 10 agents (NavMeshAgent) and automatically moving them to a deploy position. I then want to control them as a group by making each of them move to where I'm clicking. So I have a MouseController script where I check for LMB clicks. When that happens I do a raycast from the mouse position (using ScreenPointToRay), and get a position in the world to where my agents should move. So far, so good. Now comes the broken part. After getting the position from the ray trace, I try to do this:

Code:
GameObject[] agentGameObjects = GameObject.FindGameObjectsWithTag("Agent");
foreach (GameObject agentGameObject in agentGameObjects) {
	NavMeshAgent agent = agentGameObject.GetComponent<NavMeshAgent>();
	agent.SetDestination(hitInfo.point);
}

My agent prefab is tagged "Agent", so this should work. And it does, for the very first agent that was spawned. He moves to where I clicked, just like intended. The rest of them, however, do not. Instead, they throw this error:

Code:
MissingComponentException: There is no 'NavMeshAgent' attached to the "Agent(Clone)" game object, but a script is trying to access it.
You probably need to add a NavMeshAgent to the game object "Agent(Clone)". Or your script needs to check if the component is attached before using it.
MouseController.Update () (at Assets/_Scripts/MouseController.cs:16)

I really don't get this. Why wouldn't agent 2-10 have NavMeshAgent components, when they clearly did just a moment ago (every agent does the inital move from the spawn position to the deploy position just fine)? How can the first instance (clone) of my Agent prefab work correctly, but not the rest of them?

EDIT: Solved it! Apparently the issue was that I had put the MouseController script on the camera (which might not have been a good idea either way, I guess it just felt like the most appropriate place for it at the time). Moving it to an empty game object makes it work like it should. I still don't understand why having it on the camera broke everything, but oh well.
 
Oh awesome thread! I know a lot of UDK (art-side), not sure there is a thread on that -- but if anyone needs help with it, I'm down.

My unity knowledge has faded somewhat over the years, so this'll be a good thread to refresh.
 
@RoadHazard, you might want to look into Rain if you want a really full-featured pathfinding/AI system, though it's probably not as easy to set up as the other options. Admittedly I haven't really tried it myself - I came across it while looking for a path-finding solution for a game jam, and in that time-limited context it didn't seem worth the learning curve - but its feature set seemed quite impressive. I don't know if you need something that complex, but if you do give it a try, do post your impressions. :)
 
Does debugging work on VS pro and is it stable?

Debugging on Visual Studio is not possible out of the box, but there's a commercial add-on for it: http://unityvs.com/ I don't know how well it works since I don't have VS Pro and it doesn't work with Express (also I probably don't want to pay $100 for something like that at this point).

How recently have you tried Unity? They recently upgraded the MonoDevelop version included with it in 4.3 so it's better than it was... though still hardly perfect. I have some stability issues, but nothing as bad as what you described.
 
@RoadHazard, you might want to look into Rain if you want a really full-featured pathfinding/AI system, though it's probably not as easy to set up as the other options. Admittedly I haven't really tried it myself - I came across it while looking for a path-finding solution for a game jam, and in that time-limited context it didn't seem worth the learning curve - but its feature set seemed quite impressive. I don't know if you need something that complex, but if you do give it a try, do post your impressions. :)

Wait, am I missing something or is this thing entirely free? Because if so, that's amazing.
 
Anyone have any tips or best practices for setting up your object model within unity properly? Ie do I use a singleton or what? Where should the main game class for my game reside ideally? I had the basics of Unity down in the summer but stopped due to other work when I was beginning to research this question.

I personally like to use an empty game object as my "SceneController" that is sort of the base handler for a lot of the different interactions.

I also have other empty manager objects that just have scripts attached for things like my audio system, globals etc.

I'd also like to start learning Unity. My problem will probably arise from graphics, because I can program in Java and C++ without any real problems. For a 3D game I will need models though and I'm not quite confident I'll be able to make them. However, I plan on doing a 3D collectathon platformer, since I'm missing this genre so much. I've already programmed some 2D games in the past (without using an engine), but this will be a serious step up in difficulty I guess. Especially scaling objects properly in 3D depending on their distance and being efficient with what objects to compute (objects that are begind other ones shouldn't be rendered, of course). While I'm still not confident I'll be able to pull this off, a friend of mine and my fiancée are interested in helping me with level and scenario design, so I hope I'll have enough motivation.

However there are two questions I'd like to ask the NeoGAF pros:
1. Can someone recommend a good tutorial for my goal (development of a 3D platformer with Unity)?
2. Although it might not be too likely, if I end up being really happy with the end result, I'd like to play my game on a console (Wii U being the obvious choice?); can I just apply for an Indie-license and in case I get it, compile the game as a Wii U build? What would I need to keep in mind when programming my game to get it running on Wii U (or another console where I'd be able to run the game on more easily, but also cheap)? Finally, would I be able to upload my game to eShop free of charge? Because I don't want to make money with games, I just want to make a game I (and my partners) will enjoy to play and I'd like them to be able to play it on their Wii U too.


Unity used to come with a built in 3d platformer tutorial, not sure if it still does. It might be on the Unity asset shop now.

I don't know how the WiiU licensing stuff works but if it is anything like iOS you will probably have to make some minor changes after you apply the license and set your scripts to build for WiiU. The biggest thing would probably be making sure that your game is set up to work at a proper resolution or capable of handling varying resolutions. Also there's usually differences in things like how file I/O is handled and input systems. I'd check the documentation to be sure.
 
Wait, am I missing something or is this thing entirely free? Because if so, that's amazing.

Yep. :) As I understand it, they used to have a free indie version, and a commercial pro version with more features, but they eventually decided to just make everything free. Not sure what the business model is there, but that's pretty awesome.
 
I personally like to use an empty game object as my "SceneController" that is sort of the base handler for a lot of the different interactions.

I also have other empty manager objects that just have scripts attached for things like my audio system, globals etc.

I've forgotten some of my Unity, now, but as I recall everything is associated with a Scene. So based on that, where is my game controller/game object? In the menu scene? I just need a place to, say, store information for player 1 state, player 2 state, game state, etc. I feel this somehow needs to globally accessible (Hence the Singleton idea) but I'm not sure if placing a dummy object in a scene with a script attached was the best way to approach this. I guess that's the crux of my conundrum.
 
I've forgotten some of my Unity, now, but as I recall everything is associated with a Scene. So based on that, where is my game controller/game object? In the menu scene? I just need a place to, say, store information for player 1 state, player 2 state, game state, etc. I feel this somehow needs to globally accessible (Hence the Singleton idea) but I'm not sure if placing a dummy object in a scene with a script attached was the best way to approach this. I guess that's the crux of my conundrum.

I would create a GameObject called GlobalManager, and aside a script to it called GlobalManager. Then I would make the object into a prefab.

Then in the awake or init or whatever you could set the GlobalManager to "NotDestroyOnLoad" (I forget exactly how to do this but its a one line of code thing). Now the GlobalManager will persist throughout all scenes.

The last game I worked on was relatively simple, but we had a persistent GlobalManager, AchievementManager, NetworkManager and StateManager. Each scene had its own SceneController and derived StateSystem.

Mind you this game had a total of 3 scenes (title screen, gameplay, and results) but it worked out relatively well.

You should also look into using the PlayerPrefs file for player info.
 

Ecto311

Member
Read through here a bit and seen that C# is recommended for the language to use in unity. Any good resources to learn it? Books? Sites?
 
FWIW the subset of C# you use in Unity is a bit different than actual C#. Its really its own language in a way just with C# syntax and style. At least that's how I felt about it.
 

Tiu Neo

Member
FWIW the subset of C# you use in Unity is a bit different than actual C#. Its really its own language in a way just with C# syntax and style. At least that's how I felt about it.

IMO, the language is pretty much the same, with all features. The main difference is the development philosophy - component based instead of OO. There are some things that are bad practices on "pure" OO C#, but common on Unity (like public attributes), but if you know C#, it's easy to get used to it.

Knowing a bit about C# also helps on some language specific features that can make your life easier, like LINQ and Extension methods, for example.
 

Water

Member
IMO, the language is pretty much the same, with all features. The main difference is the development philosophy - component based instead of OO. There are some things that are bad practices on "pure" OO C#, but common on Unity (like public attributes), but if you know C#, it's easy to get used to it.

Knowing a bit about C# also helps on some language specific features that can make your life easier, like LINQ and Extension methods, for example.
Same language, but very old version, so new C# stuff won't work. Unity is still on Mono 2.6 which came out in 2009. In .Net terms, I think it's like 3.5 with some 4.0 features. This is because Unity doesn't want to pay whatever Xamarin is asking for a newer Mono license.
 

Yoshi

Headmaster of Console Warrior Jugendstrafanstalt
I don't know how the WiiU licensing stuff works but if it is anything like iOS you will probably have to make some minor changes after you apply the license and set your scripts to build for WiiU. The biggest thing would probably be making sure that your game is set up to work at a proper resolution or capable of handling varying resolutions. Also there's usually differences in things like how file I/O is handled and input systems. I'd check the documentation to be sure.

Thank you :). I can't look up the documentation though, because I don't have an Indie-license for Wii U; I'd only apply for one, if the game I want to make turns out to be fun enough for me to try put it there. I hoped maybe someone here is already developing for Wii U and could answer this easily, but your answer is already very helpful :).
 
Top Bottom