Mapping Actions to a Node-based editor using Unity3D - unity3d

My question revolves around how to get behaviours described by a node-based editor to map to actions in-game. I've searched for several weeks about how to do this but can't find anything. If anyone could point me in the right direction, I'd be really grateful!
I don't know the best way to ask this question - I don't want to overload the question with what I've done, so I'll elaborate a bit below, as best I can:
I currently have a custom node-based editor I wrote for Unity, which I use to graphically edit the behaviour of bosses and NPCs. It looks like this (with the right-click menu shown):
I did find a way to get this behaviour working in-game, but it feels wonky and I'm wondering if there's a better way.
The way it works is there are two objects to be serialized per node object. I currently have these setup as scriptable objects, though if I were to do this again I'd create my own kind of serialization. These two objects are:
The Node in the editor window, containing editor scripts
The associated in-game action, to be loaded by the NPC at runtime
This creates a bit of mess in the file structure, as well as the amount of script files I need. On top of this, it's a bit tricky to manage cases where multiple actions are being performed simultaneously, and I need to change the NPC's state (e.g. phase1 to phase2 of a boss fight), which sounds to me like a design issue.
I'd be happy to share source code or more screenshots, if at all necessary. What I'm looking for is a way to approach something like this in a structured way that allows scalability for other projects (e.g. NPC behaviour for an RTS)

Related

Unity modular NPC

We are developing a Top Down RPG Game. So, there's a question about NPCs. Making a lot of NPC FBX files would not be optimal. From what I know, people usually make 3-4 bodies and a bunch of heads, so the NPCs would look different. Do you guys have any idea, if there's an optimal way of doing that?
I tried modelling bodies and heads in separate files and then putting heads onto the empty object on top of the body (this empty object was part of the FBX itself). It didn't work, as the actual head always displayed too high above, so it looked like the head was hovering in the air.
I also thought about making heads a part of one big FBX with just one body. So all the head would be on the same coordinate in space, and so in Unity there would be a possibility of making active just one head in time. I still don't think it would be very optimal.
So, is there a way people usually do this? I mean, this must be really common. They used it in Gothic, for sure and in many other games. So there must be an optimal way, but I'm unable to find it.
There are a few character customization packages available on asset store that you could use. I recommend UMA2 (Unity Multipurpose Avatar). It is a perfect tool and I'm using it on one of my projects and it's really gets the job done. And the good thing is that it's free. Once you imported it into your project, you can either buy contents (cloth, hair, face, ...) or create your own contents like I do using blender. There are tutorials about how to integrate and create contents on Secret Anorak youtube channel.

Tracking a 2 dimensional sprite in Java

I'm kind of new to this whole thing but I'll get started by asking my first question ever.
So a friend and I are working on a project in which we need to track the player character's head movement and attach items to it. Now is this something that needs to be done in Java or would this be something that would be done in Unity?
Sorry if this is a stupid question but I've never really worked on a project of my own volition before.
Thanks,
BadAssWalrus
Ok, so first things first. There is no java in unity, you can do scripting in C#, UnityScript (essentially JavaScript) or Boo.
Now to answer your question, according to my understanding you want to move some objects as the head of the character moves. Now depending upon how you are really trying to move the objects you could either do it with scripting or simply by making the object you are trying to move a child of the head of the character.
Unity has excellent documentation about the scripting API and a lot of tutorials. I suggest you get started by looking at one of these tutorials, and you should get an idea of how things work pretty soon and then you should be able to do pretty much anything you want to do with relative ease.

Show the history of a State Machine/Workflow

I'm trying to find a way to represent graphically the history of an operation inside an state machine. So if the operation has gone through state_1>state_2>state_3>state_2>state_4>end I would like to see that path visually.
We are using a Web-UI and a Java Backend, so any HTML-JS or Java library (that creates image files or something like this) should be ok for us. We are using JBMN for parts of the state machine, my initial approach was to find something related with it, but I haven't found anything
Any ideas?
Do you want to do some crazy animations? or just highlight the states that were already executed?
If you want to do that, you can use the jbpm designer that already provide that functionality.
Cheers

advice on note keeping and navigating legacy code

I"m having to work with legacy code (mostly CFML) with very little or no documentation, no domain model of any sort to follow either.
To start building some sense out of it, I though 'start keeping notes', then wondered if plain old journal and pencil for text notes would do. Maybe a text document (searchable). Or is it best to take the plunge and UML the beast over time? If that's an overkill on one hand, on the other I repeatedly find myself feeling around the elephant over and over again. How do you build a up a map of the territory?
Sorry for the late answer, but I've ended in situations like this couple of times before. I'd suggest you not to create UML for that, since it will take much time and this code is not very nice, as you've noted (no domain model, no structure).
You could use pen and paper, or text file. Browse through the code, find the most important parts for you and write down where it is located, with some description. If there is no data structure, you could use file name, module, line number, etc. After spending some time doing this, you will have something like navigation plan for the part of the system and general understanding of how it works.
Also, you should refer to this question, there are some answers that can be useful.

Getting Started with an IDE?

Having programmed through emacs and vi for years and years at this point, I have heard that using an IDE is a very good way of becoming more efficient.
To that end, I have decided to try using Eclipse for a lot of coding and seeing how I get on.
Are there any suggestions for easing the transition over to an IDE. Obviously, some will think none of this is worth the bother, but I think with Eclipse allowing emacs-style key bindings and having code completion and in-built debugging, I reckon it is well worth trying to move over to a more feature-rich environment for the bulk of my development worth.
So what suggestions do you have for easing the transition?
Eclipse is the best IDE I've used, even considering its quite large footprint and sluggishness on slow computers (like my work machine... Pentium III!).
Rather than trying to 'ease the transition', I think it's better to jump right in and let yourself be overwhelmed by the bells and whistles and truly useful refactorings etc.
Here are some of the most useful things I would consciously use as soon as possible:
ctrl-shift-t finds and opens a class via incremental search on the name
ctrl-shift-o automatically generates import statements (and deletes redundant ones)
F3 on an identifier to jump to its definition, and alt-left/right like in web browsers to go back/forward in navigation history
The "Quick fix" tool, which has a large amount of context-sensitive refactorings and such. Some examples:
String messageXml = in.read();
Message response = messageParser.parse(messageXml);
return response;
If you put the text cursor on the argument to parse(...) and press ctrl+1, Eclipse will suggest "Inline local variable". If you do that, then repeat with the cursor over the return variable 'response', the end result will be:
return messageParser.parse(in.read());
There are many, many little rules like this which the quick fix tool will suggest and apply to help refactor your code (including the exact opposite, "extract to local variable/field/constant", which can be invaluable).
You can write code that calls a method you haven't written yet - going to the line which now displays an error and using quick fix will offer to create a method matching the parameters inferred from your usage. Similarly so for variables.
All these small refactorings and shortcuts save a lot of time and are much more quickly picked up than you'd expect. Whenever you're about to rearrange code, experiment with quick fix to see if it suggests something useful.
There's also a nice bag of tricks directly available in the menus, like generating getters/setters, extracting interfaces and the like. Jump in and try everything out!
One thing that helped me transition from Emacs to other IDEs was the idea that IDEs are terrible editors. I scoffed at that person but I now see their point.
An editor, like Emacs or Vim, can really focus on being a good editor first and foremost.
An IDE, like Visual Studio or Eclipse, really focuses on being a good project management tool with a built in way to modify files.
I find that keeping the above in mind (and keeping Emacs handy) helps me to not get frustrated when the IDE du jour is not meeting my needs.
If you've been using emacs/vi for years (although you listed both, so it seems like you may not be adapted fully to one of them), using said editor will probably be faster for you than an IDE. The level of mind-meld a competant emacs/vi user can achieve with a customized setup and years of muscle memory is astounding.
Some free ones:
XCode on the Mac
Eclipse
Lazarus (Open Source clone of Delphi)
Visual Studio Express
Editions
Try making a couple of test applications just to get your feet wet. At first, it will probably feel more cumbersome. The benefits of IDEs don't come until you begin having a good understanding of them and their various capabilities. Once you know where everything is and start to understand the key commands, life gets easier, MUCH easier.
I think you'll find IDE's invaluable once you get into them. The code complete and navigation features, integrated running/debugging, and all the other little benefits really add up.
Some suggestions for starting out and easing transition:
- start by going through a tutorial or demonstration included with the IDE documentation to get familar with where things are in the GUI.
- look at different kinds of sample projects (usually included with the IDE or as a separate download) for different types of areas you may be coding (web applications, desktop applications, etc) to see how they are laid out and structured in the IDE.
- once comfortable, create your own project from existing code that you know well, ideally not something overly complex, and get it all compiling/working.
- explore the power! Debug your code, use refactorings, etc. The right click menu is your friend until you learn the keyboard shortcuts just to see all the things you can do. Right click different areas of your code to see what is possible and learn (or re-map) the keyboard shortcuts.
Read the doc...
And see what shortcuts/keybindings equivalents are with your familiar ones. Learn the new ones...
Old question, but let me suggest that in some circumstances, something like Notepad++ might be appropriate for the OP's situation which may be encountered by others. Especially if you are looking for something lightweight, Notepad++ can be part of a developer's arsenal of tools. Eclipse, Visual Studio and others are resource hogs with all their automagic going on and if you are looking to whip out something pretty quick with a whole bunch of keyboard shortcuts and the like or if you are interested in viewing someone else's source, this can be quite useful. Oh yeah, and it is free too.