so I am a beginner at unity and cannot grasp how you are supposed to have a pattern or architecture with unity.
I am currently making a platform game which has a character that is supposed to stay on moving platforms and not fall off the screen (very basic). On the platform there are "monsters". If you touch these monsters you also lose. There is also some trees and such on the platform.
This is what I have so far:
In the "manual gameobject list" or whatever you call it:
Directional light
Main camera
Background (just a sprite that is always showing)
Player (contains a JS script that has character specific code for jumping and such)
Platformspawner (Contains only a c# script. This script spawns multiple platform gameobjects, these gameobjects then use a script called platform.cs. This class spawns monsters and the trees on each platform. The monsters and trees each use their own c# file that keeps track of collisions and such.)
For me this is pretty obvious code and I do not know how to organize it much better. Any tips? I tried following an MVC tutorial but it seems like there is not much gameobject spawning in those tutorials which is what I have to do, so they confuse me.
Your hierarchy (the area of the editor where all of your GameObjects are stored) looks pretty solid. You typically don't need much organization in there if your program is pretty small, but of course putting things into folders (for example, putting multiple canvases into a large Canvas folder) can't hurt.
As for your project, where all of your assets are stored, I believe that folders are paramount for good organization, because if you combine all of your assets it'll be hard to distinguish them. I recommend having base folders for different types of assets (/Scripts/, /Materials/, /Prefabs/, etc.) and storing individual assets in there (and of course adding more folders as you see fit). You should almost never have to have an asset directly in the /Assets/ folder.
Of course, that is only my opinion and my method of organization. Everyone has a different method of managing their project, but what I've described above is the basic system of organization. Happy coding!
Related
I am currently using the NVIDIA FleX package in Unity3D to create soft-bodied, jelly objects. I'm using Unity for animation only, not game dev.
What I am aiming to make is a transparent, jello sphere that retains its spherical shape with elasticity.
The first way I've tried to achieve this is using Flex Array + fluid setting. I've been playing with the settings but I can't get it to remain a sphere, it just becomes a more/less viscous fluid blob.
The second way is using the Flex Soft + fluid setting. It is much better in terms of physics but even with "draw particles" off, but the water droplets are each separated and not one jelly sphere.
This is what it looks like before hitting play, where the left is with Flex Array and the right is Flex Soft. The particles for Array are visible but not for Soft.
This is after hitting play, where the Array becomes one viscous fluid, but not a sphere, and the Soft is very jello-like but the water droplets are all separated.
A solution for either of the two ways would be much appreciated!
the standard approach is to create an Nvidia Flex Controller first...
Then you should also create a Flex Soft Asset...
Then you should create or select a game object and through the Add Component tab in the game object's inspector, find the Flex Soft Actor component [see it loaded up in the image below]...
Ensure your Soft Actor Asset mentioned previously has your required mesh type selected in the inspector option [I chose sphere in the image here] and check to see it looks something like the image below to be sure...
So after that, hopefully, you can just press play and see it in action as it drops and contorts for you.
If not, I have created a quick example for you to download as a unitypackage.
It may still require further resolution with the package manager as the Flex plugin is already inside the package I'm providing here[Using Unity 2020.3.5f1]
Flex in unity package
Anyway, hope this gets you started and somewhere towards your goal with Flex.
As a bonus, I've added a small script to move the flex object as this is outside of the usual approach as we have to call to the NVidia Flex component class of choice and invoke the ApplyImpulse method.
Cheers :)
Edit: There are a small 3 set of tutorials from NV Gameworks on integrating the plugin with Unity and exampling some stuff - this "stuff" is included in my downloadable package provided above.
Here is the youtube link to the 3 set:
Nvidia Gameworks FleX tutorials on Youtube
Edit 2: rereading your question made me think I hadnt really given you the definitive answer as to using a cloth actor and having the mesh renderer deform via the flex cloth deform component.
I am providing another link to another unity package here that will show this in action also allowing you to see the game object and how the cloth component from NVIDIA Flex works with the standard mesh filter and mesh renderer. Hope this more accurately answers your question :)
Example also using Cloth Actors as well as Soft Actors in NVIDIA FleX
I want to change some game assets like backgrounds, images and buttons for another ones for an event and I want to let the players switch between the UI skins wherever they want.
Tested creating some GUI Skin but I think thats not what I want.
Right now, before build the game, I manually copy and paste new assets and replace old ones so the files have the same name and Unity changes every image in the game that uses that sprite. When the event finish I do the same with the old images. Bu I want to change that with just a button.
I know I could do the cahnge one by one but, there is any way to do this change withouth having to set all image sprites one by one? maybe changing the "baseSprite" name to "baseSpriteTemp" and the "eventSprite" name to "baseSprite"?
Any idea?
GUISkin is what you would use with the Immediate Mode GUI system, i.e. drawing in script OnGUI functions.
If you are talking about in game assets for the UI and other items, you have options:
Roll your own theming system
Use AssetBundle Variants
Use Addressable assets
I have used asset bundle variants in the past, and they were pretty easy to setup.
Addressables are a newer feature, and as such I have had little experience, but it looks like it can work for what you are looking for.
I am building an app for the HoloLens gen 1 device using Unity 2018.3.13f and MRTK V2 RC1. I got a simple AR design with 2 text objects and 1 rawimage object. After building the project and deploying it to the HoloLens the AR objects ends up behind the spatial mesh (you know all those spatial triangles), but I want all the objects to be in front of the wall.
How do I accomplish this?
The canvas is set to be on the main camera
I have the original settings for the DefaultMixedRealityconfiguraitonProfile if there is something there that needs to be changed.
This is how it looks through the hololens with the app when it does not show the mesh of the wall (sorry for the bad quality)
and this is how it looks when it falls behind the mesh
Do I need to add some mesh renderer or something on the MainCamera to make this possible?
Any help is appreciated, thanks!
I don't believe that the MRTKv2 as of 2019/5/9 has code that will auto-ensure that a specific object is positioned in between the camera and other arbitrary meshes and colliders (i.e. the spatial awareness is one such mesh, though you could imagine just having an arbitrary box or plane in the scene that would occlude that object, in which case, maybe you'd want your "in between" object to stay in between both those two types of potentially occluding things).
There used to be a script in the HTK called Tagalong.cs that would do something like this by doing raycasts from the camera to collidable object:
https://github.com/microsoft/MixedRealityToolkit-Unity/blob/htk_release/Assets/HoloToolkit/Utilities/Scripts/Tagalong.cs
This single large script I think got broken up into smaller scripts (i.e. specific behaviors in the solvers here:)
https://github.com/microsoft/MixedRealityToolkit-Unity/tree/mrtk_release/Assets/MixedRealityToolkit.SDK/Features/Utilities/Solvers
However, from what I can tell, the specific interaction of "keep things automatically between the camera and whatever collidable object" wasn't preserved. Someone else can correct me here if I'm wrong, it looks like this wasn't a behavior that got preserved in V2.
Going forward, there are a couple of possibilities:
1) Probably file an issue on Github here (https://github.com/microsoft/MixedRealityToolkit-Unity/issues) to request this feature be ported over.
2) Use the code in Tagalong.cs to add your own solver that would accomplish this (i.e. the code looks to be all there, there's just some work needed to get done to reorder it to handle what you want)
If you use a sprite renderer, set order in layer (into 0 or -1).
If you use a mesh renderer, try to deactivate dynamic occluded.
Try to change the hierarchy of the sorting layers under Edit-> Project Settings -> Sorting Layers
i recently downloaded "Tiled Map Editor" - because i heard it was a great tool for making maps. I also got a .tmx "compiler", well, something that made the .tmx usable in XNA.
I've created a map and imported it and it worked fine, but now the tricky part comes...
If i add a collision layer in "Tiled" and adds a tile that indicates block part, how would i get data and values, and how would i be able to use it in XNA? And how would i make so that the player spawns in a certain location, and also, how do i add things as events, and movable objects?
You don't have to tell me everything that, but it would be cool if you could give me an idea on how to get data and values from the .tmx and convert it into rectangles or such things^^
Thanks in advance!
I know nothing about tmx file but a little about collision.
I'm going to take a punt that your ".tmx "compiler"" is something that allows files of this type to be included in the content pipeline. Somewhere in this build process will be the vertex data that you can use to construct the collision primitives (shapes) for collision detection later.
ASIDE: it took me ages to get my head around the content pipeline - not for the faint hearted but the way to go. They are samples on the XNA website to get you going
I'm learning 3D programming and I decided to make a really simple "engine" where you can just fly around the map, etc. Only basic rendering of walls.
So, I was thinking - how can I save the level and how can I edit it. I don't want to make also an editor for it, because it is only a learning project, and not an actual game. So, I was looking towards this level format: UDMF http://zdoom.org/wiki/Universal_Doom_Map_Format although it is for a completely different type of game, still, it does what I need. Specifies vertices, floor, ceiling positions, etc. So, basic 2.5D geometry, which could be easily interpreted into a 3D space, which is more than enough for my purposes. There are also tons of editors (main reason).
BUT, I do realise that this is not really the best solution, and kind of workaround.
So, my question: Is there any "open" map format and "open" editors that I can use for my engine/game?
UPD: I'm working with C# and XNA, if that is important.
You could use XML (or something even simpler) that provides the location and other attributes of all the objects in the level. This would be the easiest solution (and have the benefit of containing whatever info you want but nothing else) but would not provide a level editor.
However, I know you want an editor (who wouldn't). Here is a very new, work-in-progress editor that looks interesting: 3D Scene Editor for XNA