• Unity3D - Discussion
    5,004 replies, posted
Anyone play with the particle system? How easy was it to use?
[QUOTE=Johnny Guitar;43148973]Anyone play with the particle system? How easy was it to use?[/QUOTE] Pretty easy but imo hard to make interesting and different stuff.
[t]http://i.imgur.com/W54v3eK.png[/t] Working on a space game type thing for class.
Looks sweet!
So I'm trying to add a Singleton pattern to my test game and was wondering what can I improve on? Right now I basically have 2 cubes so when you walk into them, it adds 100 or decreases 100 from your final score depending on what cubes you walk into. Here is an example of the code for 1 cube: [CODE]public class DecreaseScoreCube : MonoBehaviour { void OnTriggerEnter(Collider collider) { ScoreManager.Instance.DecreaseScore (100); } }[/CODE] And my ScoreManager looks like this: [CODE] private static ScoreManager managerSingleton; private int FinalScore; public static ScoreManager Instance { get { return managerSingleton; } } protected void Awake() { managerSingleton = this; } public void AddScore(int scoreToAdd) { FinalScore += scoreToAdd; } public void DecreaseScore(int scoreToDecrease) { FinalScore -= scoreToDecrease; } void OnGUI() { GUI.Box(new Rect(450,10,150,25), "Final Score: " + FinalScore); }[/CODE] Any ideas on how I can improve this?
[t]http://i.imgur.com/O1kjVf2.png[/t] Added a lens flare to replace the godrays I was using prior, JJ Abrams style. I also added some stars to the background and the ship now has a new super cool design that isn't a floating cube not bad for 1 day of work. EDIT: What should I do about the trails following planets, they add a cool touch but I feel like they are still out of place.
[QUOTE=Over-Run;43153418]So I'm trying to add a Singleton pattern to my test game and was wondering what can I improve on? Right now I basically have 2 cubes so when you walk into them, it adds 100 or decreases 100 from your final score depending on what cubes you walk into. Here is an example of the code for 1 cube: [CODE]public class DecreaseScoreCube : MonoBehaviour { void OnTriggerEnter(Collider collider) { ScoreManager.Instance.DecreaseScore (100); } }[/CODE] And my ScoreManager looks like this: [CODE] private static ScoreManager managerSingleton; private int FinalScore; public static ScoreManager Instance { get { return managerSingleton; } } protected void Awake() { managerSingleton = this; } public void AddScore(int scoreToAdd) { FinalScore += scoreToAdd; } public void DecreaseScore(int scoreToDecrease) { FinalScore -= scoreToDecrease; } void OnGUI() { GUI.Box(new Rect(450,10,150,25), "Final Score: " + FinalScore); }[/CODE] Any ideas on how I can improve this?[/QUOTE] I suppose you could just make the script that is attached to the cube to have a single nuber variable that could be changed to any positive or negative number, you shouldn't need to have 2 scripts and functions for just adding and subtracting a value.
[QUOTE=nVidia;43157315]I suppose you could just make the script that is attached to the cube to have a single nuber variable that could be changed to any positive or negative number, you shouldn't need to have 2 scripts and functions for just adding and subtracting a value.[/QUOTE] Thanks. I read somewhere that the singleton I added in isn't a proper singleton as the constructor isn't private or something? Is that right?
[QUOTE=Over-Run;43157524]Thanks. I read somewhere that the singleton I added in isn't a proper singleton as the constructor isn't private or something? Is that right?[/QUOTE] Sorry, I do not know. :v: Maybe someone with actual programming know how can answer that.
[QUOTE=Over-Run;43157524]Thanks. I read somewhere that the singleton I added in isn't a proper singleton as the constructor isn't private or something? Is that right?[/QUOTE] Unity classes that you make shouldn't have constructors. The awake function fulfills this purpose, which should always be written as private afaik.
So if I have [CODE] private void Awake() { managerSingleton = this; }[/CODE] It should be a singleton design pattern now? Do you know anything about canonical classes in Unity?
I'm not sure if it's a perfect by-the-rule example of a Singleton but it would probably function as one, assuming you've tested it. And I don't even know what canonical classes are :v:
Yeah I just need to try find out if it's a proper implementation because we have to implement some design patterns for a Design Pattern module :P The pattern is working, it does increment and decrement the score so I guess it works. Canonical classes are classes that implement Serializable and Cloneable I think, so I duno how that would work in Unity. I implemented an ObjectPool pattern like you suggested. At the moment it works by me clicking the mouse and a ball shoots out from some location on the map, and disappears. Could I make it so that by pressing the number buttons I can change the type of object that gets shot? For example make it a cube or something? Like is an ObjectPool only used for 1 type of Object or can it be used for multiple?
[QUOTE=Over-Run;43158113]Yeah I just need to try find out if it's a proper implementation because we have to implement some design patterns for a Design Pattern module :P The pattern is working, it does increment and decrement the score so I guess it works. Canonical classes are classes that implement Serializable and Cloneable I think, so I duno how that would work in Unity. I implemented an ObjectPool pattern like you suggested. At the moment it works by me clicking the mouse and a ball shoots out from some location on the map, and disappears. Could I make it so that by pressing the number buttons I can change the type of object that gets shot? For example make it a cube or something? Like is an ObjectPool only used for 1 type of Object or can it be used for multiple?[/QUOTE] Have a list of objects that you can fill with whatever you want in the inspector, then when you want to instantiate something you refer to the list with an index that can be changed somewhere with user input. If you don't want to fill the list manually you could populate the list using Resources.Load.
[QUOTE=Johnny Guitar;43156068][t]http://i.imgur.com/O1kjVf2.png[/t] Added a lens flare to replace the godrays I was using prior, JJ Abrams style. I also added some stars to the background and the ship now has a new super cool design that isn't a floating cube not bad for 1 day of work. EDIT: What should I do about the trails following planets, they add a cool touch but I feel like they are still out of place.[/QUOTE] What's this game about? What does the player do?
[QUOTE=nVidia;43158139]Have a list of objects that you can fill with whatever you want in the inspector, then when you want to instantiate something you refer to the list with an index that can be changed somewhere with user input. If you don't want to fill the list manually you could populate the list using Resources.Load.[/QUOTE] Yeah the way the ObjectPool is working at the moment is that I created a sphere game object, added it to a prefab, and then used Resources.Load. So I can add several game objects and load them with that then?
[QUOTE=Pelf;43158315]What's this game about? What does the player do?[/QUOTE] No idea, I usually have some sort of idea as to what I want to do with most projects but I've been tweaking this a lot. However that being said the idea that I've had in the back of my head while working on the map is exploration and finding neat new stuff to upgrade your ship with.
What's the best way to handle playing of audio? Should I have a single audio handler script that plays sounds depending on conditions in the game or should sound playing be handled by each script that should play sounds? For example, pressing W makes the engine thrust and should play a sound. Crashing should play an explosion sound. Missiles detonating should play an explosion sound. Various ambient effects should play depending. [editline]12th December 2013[/editline] [QUOTE=Johnny Guitar;43158438]No idea, I usually have some sort of idea as to what I want to do with most projects but I've been tweaking this a lot. However that being said the idea that I've had in the back of my head while working on the map is exploration and finding neat new stuff to upgrade your ship with.[/QUOTE] Sounds cool. Maybe have the planet orbits be marked by a line of sorts like KSP mapview but the lines can be toggled?
I had to develop a game for a uni module. We chose Unity and its new 2D features. [URL="http://htf.me/bird/"]Here is the result (Space or click to go up, esc to pause).[/URL] I did all the Unity dev work, had a couple of artists and a sound guy as well. All assets are original except the play icon on the menu.
Is object pooling the pattern where you preload/cache/buffer/whatever-the-term-is several copies of an object into memory and keep reusing them over and over again instead of fire-and-forget (instantiate new ones when you need them)? Like: 1) On game start, create 40 copies of bullet, set it to inactive and store it 2) "Take it out" when you need to use it 3) When the bullet hits something, instead of calling Destroy(gameObject) set it to inactive and put it back to the pool. 4a) If all bullet is active on scene and trying to shoot another bullet, the oldest will be recycled (or simply ignore the request). 4b) If all bullet is active on scene and trying to shoot another bullet, instantiate a new one (not connected to the pool) Is that it? If so then each type of object needs a pool. However, quick google shows that it is possible to only use one pool for different types of object (using Dictionary). Do it in a way you are most comfortable with (in terms of code, debugging, and FYP presentation). You might want to check out ScriptableObject or [System.Serializable], maybe you can find answers for canonical classes. I don't know what that is.
Working on ship customization for the space thingy, I currently have it so engines have a fuel consumption rate, a speed that they travel at, the rate that the ship rotates at. Now I really have to ask, what more should I add in? I'm thinking of drills and some sort of asteroid mining thing.
Finish up your core mechanics. Further deviation from it will make your game full of feature creeps. You said its about exploration and finding cool stuff to mod your ship, and you have a working plus moddable movement system. Start creating the upgrade system?
Finally bothered to spend a few hours understanding Octrees (well I understood them, but not from a coding perspective, I had no idea what I was doing and clear documentation on it is kind of hard to find). After 4 hours of coding I have a working Octree on a GameObject basis, dynamic size and depth. Right now for testing purposes I'm drawing the blocks with gizmos and clearing the octree + inserting them in real time in the editor so I can move the test objects around while visualizing what is happening. Already coded it so it merges blocks with the same ID if possible, replacing the 8 blocks with a bigger one (as you can observe by looking at the 2x2 block in the screenshot, the others are 1x1), the octree size is 16x16 but I can make it whatever I want within acceptable dimensions, as well as change how much depth it allows me to go when inserting voxels. [img_thumb]https://dl.dropboxusercontent.com/u/9133125/Octrees.png[/img_thumb] My goal is to get it to a point where I can generate Minecraft-like worlds, then I'm thinking of moving to rendering the voxel data with other methods besides blocks (surface nets, etc) but I'm trying not to think too far ahead.
[QUOTE=secundus;43167866]Finish up your core mechanics. Further deviation from it will make your game full of feature creeps. You said its about exploration and finding cool stuff to mod your ship, and you have a working plus moddable movement system. Start creating the upgrade system?[/QUOTE] -snip figured it out, unity is awesome, ect-
[QUOTE=LuaChobo;43175929]ludum dare here we go[/QUOTE] Got assignments due in so going to skip it and do the Global Games Jam in January instead.
Had a play with dynamic cubemaps [vid]https://dl.dropboxusercontent.com/u/3590255/OBS/obs_output_%20%2809%29.mp4[/vid]
Making 1v1 sub hunt game for Ludum Dare. Each player has a sub and they cant see anything so they have to send out sonar pings to see the other player and the world. They only have one torpedo so whoever does the most damage to the other player wins. There's a time limit too. [t]https://dl.dropboxusercontent.com/u/13781308/ShareX/2013-12/2013-12-14_10-08-24.png[/t] That glow is short-range sonar that's always on. It's for navigating the seafloor easier. [editline]14th December 2013[/editline] Sonar ping casting and reflection: [t]https://dl.dropboxusercontent.com/u/13781308/ShareX/2013-12/2013-12-14_10-52-39.png[/t] [t]https://dl.dropboxusercontent.com/u/13781308/ShareX/2013-12/2013-12-14_10-53-24.png[/t] [editline]14th December 2013[/editline] More sonar pings [video=youtube;UhW9FWs5HXM]http://www.youtube.com/watch?v=UhW9FWs5HXM[/video] [editline]14th December 2013[/editline] What's the best way to find out the cause of a crash in Unity free? Without the profiler?
[QUOTE=Pelf;43180323]What's the best way to find out the cause of a crash in Unity free? Without the profiler?[/QUOTE] Is it the game crashing or the editor crashing? Unity dumps a log file when it crashes so you might want to look into that.
Networking! [t]https://dl.dropboxusercontent.com/u/13781308/ShareX/2013-12/2013-12-14_22-09-18.png[/t][t]https://dl.dropboxusercontent.com/u/13781308/ShareX/2013-12/2013-12-14_22-09-32.png[/t]
Authoritative or non-authoritative?
Sorry, you need to Log In to post a reply to this thread.