• Unity3D - Discussion
    5,004 replies, posted
Yeah something like that(but not that) was what I was thinking but that's directly using logic gates unlike what Drury suggested.
Is the performance of GetComponent much of a concern if I'm calling it 1-5 times/frame? Or is it just the Find functions that are really slow?
[QUOTE=Pelf;45580547]Is the performance of GetComponent much of a concern if I'm calling it 1-5 times/frame? Or is it just the Find functions that are really slow?[/QUOTE] If it uses a Dictionary<,> it shouldn't matter, those are stupidly fast. The official documentation mentions caching them though if you use them really often. I doubt it's a problem except if you have a very complicated set-up with tons of them. [editline]3rd August 2014[/editline] If it ever becomes a problem (and Unity has hooks for composition), you could use my Components library to avoid caching them manually. It's on my Bitbucket, licensed under LGPL. It's not a specific Unity library though, which is why you'd have to hook into composition centrally yourself to make it work.
I would cache them because it is good to get used to (make a habit) caching stuff anyway. Tamschi, link to library?
[QUOTE=Fourier;45581558]I would cache them anyway because it is good to get used to caching stuff anyway. Tamschi, link to library?[/QUOTE] Library: [URL]https://bitbucket.org/Tamschi/components[/URL] Bundle repository with examples: [URL]https://bitbucket.org/Tamschi/components-bundle[/URL] (clones library automatically) This requires Reflection.Emit being available, but if you don't mind lower linking performance you can rewrite the linker with lambdas + reflection only. Note that this requires a bit more memory than Unity's GetComponent alone due to effectively duplicating the references in the local properties. It's originally meant as fire-and-forget system that delegates resource management to the GC only. [editline]3rd August 2014[/editline] Well it's exactly as efficient as manually implementing the stuff after linking, I just mean it would still work with the properties alone without actual entities. It doesn't support lazy allocations (though on second thought that's generally impossible with static typing anyway). [editline]3rd August 2014[/editline] Can entities in Unity have more than one Component of the same type? (I'm mostly asking for a different project, my library supports it anyway (with a bit of extra bootstrapping since I didn't add multi-links).) [editline]3rd August 2014[/editline] Sorry for the rambly post, I should eat something. If anything's unclear just ask. I'd also be happy about contributions, it's not quite as readable as I'd like either. If you need some special additional feature I may look into it, but if it's something I don't have use for I very likely wouldn't do it for free. (I'm trying to get into monetizing some of my projects, if possible.) [editline]3rd August 2014[/editline] Actually, I think I used Expressions so you should be able to execute them without compiling if the platform doesn't support it. Components doesn't have a code path for that though.
[QUOTE=KillaMaaki;45562669]Well, something clearly isn't right elsewhere. LoadLevel doesn't just randomly fail, so I'm thinking something else is failing and causes the game to throw a fit. Try reducing your redirect scene down to nothing but that script and the required GUIText, and possibly even get rid of the Screen.orientation call. Check if it still happens.[/QUOTE] I know it's been 2 days ago but I just had time to check this. I deleted the 2 scenes that I've been using to redirect the scene. What I do now is put that in each scene and after 2 seconds activate 2 objects that are containing everything. I commented out ScreenOrientation and is still doesn't do anything, I think it has to do with yield. [code] //Gatherinformation public GUIText loadingText; //All GameObject public GameObject menu; public GameObject mainObjects; void Awake() { //Set the view orientation //Screen.orientation = ScreenOrientation.Portrait; } void Start() { //Setting the Text loadingText.text = "Loading..."; StartCoroutine(RedirectSeconds()); } IEnumerator RedirectSeconds() { Debug.Log("I am waiting"); yield return new WaitForSeconds(2); Debug.Log("It's done"); menu.SetActive(true); mainObjects.SetActive(true); gameObject.SetActive(false); } [/code]
Does the initial "I am waiting" text get printed?
Yes, that's why I was thinking that yield is not working.
Been messing around making fire spread in my free time, It's kinda basic right now but this is what it looks like so far: [vid]www.seanscorner.com/firespread3.mp4[/vid] [Edit: Video doesn't seem to work when embedded. Here's a direct link: [URL="http://www.seanscorner.com/firespread3.mp4"]www.seanscorner.com/firespread3.mp4[/URL]] I'm using 2 raycasts for the firespread, one which checks directly upwards and another which checks from above (at a randomly angled position) and casts towards the center of the parent of the fire. It seems to work really fast even with hundreds of active fires, although I'm clearing fires after they've been alive for a random time too. For checking if a fire can spread to the position I am comparing the position it's trying to create with a generic list which stores information about all the fires using Vector3.distance (Although this starts to get pretty intensive in the profiler after a lot of fires have been created so I will probably look into using a dictionary or something as I have no idea if that would be faster) A previous method I was using was to have particle colliders on all the fires and use OnParticleCollision to create new fires from that, but it's incredibly slow when the fires start to build up..
-snip- Missed a whole page.
[QUOTE=reevezy67;45579184]I have no idea how I would go about doing that.[/QUOTE] RPG with logic gates being a hacking minigame, for instance. You can either grind your lockpick skill to insane levels or just use your logic gate knowledge for free access.
Not sure if I asked this before or not but how can I resize the font based on the screen resolution.
[URL="http://blogs.unity3d.com/2014/08/04/multi-scene-editing/"]A new blog post about multi scene editing.[/URL] Looks amazing, gonna be forever until we get it though.
[QUOTE=Pelf;45580547]Is the performance of GetComponent much of a concern if I'm calling it 1-5 times/frame? Or is it just the Find functions that are really slow?[/QUOTE] If the component is on the object for the entire duration of the lifespan of the object, I'd just play it safe and store it in a field and get it once in the Start() method. I've certainly not seen a performance hit when being lazy and updating a few labels with that, however.
I present to you; spooky scary ghosts: the video game [video=youtube;y086mJ1xB0Q]http://www.youtube.com/watch?v=y086mJ1xB0Q[/video] (remember folks; 1080p is best p) And I have now done enough to do a changelog; - Now includes navmesh that works and can make things actually navigate it - Added base NPC script - Added shadow alien guys (so spooky) - Added basic NPC behaviour system: - Behaviours are stored in a central dictionary in game - NPCs have a number of behaviours that they are allowed to use - Behaviours can link up with each other and decide which should be used based on importance (not really but the maths for it is there) - Made the Mobile Engineering Platform follow the navmesh so it doesn't clip through trees and stuff - Updated a load of the logic gates and stuff that I use for map events, so they can reset - Added Player health - Added the ability to damage the Player (along with effect!) - The strange radio towers that were only for decoration now have a purpose; they save you from the spooky shadow aliens. Additionally, I've started to improve the viewmodels of the tools/weapons you can get (meaning the two tools that I've come up with). It's kinda crazy, it's only been a couple of months but you can see how much I've improved at this modelling business; [img_thumb]https://dl.dropboxusercontent.com/u/107588088/drillBetter2.png[/img_thumb] The other things I've done are: Wrangled a voice actor for one of the two characters that actually speak and started writing a test script to get my bearings (thankfully I've written scripts before so this isn't too hard - though I won't post it here because this isn't the creationism corner), and might be getting some really nice art for a character selection screen soon. Only time will tell. Probably.
That looks amazing, do you want to release a proper game or just messing around?
[QUOTE=BoowmanTech;45597175]That looks amazing, do you want to release a proper game or just messing around?[/QUOTE] Thank you very much, and I have absolutely no idea! I had a few months away from uni studies, and as I only work part time I thought I'd start a project. My only goal is to make a game I like (I'm 19 and have been doing small games since I was 8, still hasn't happened yet!), so releasing it or selling it etc really hadn't occurred to me. Maybe if some people want me to, but I'm always paranoid about the quality of my work (for example steam early access makes my skin crawl) [QUOTE=Luafox;45597260]I'm impressed by the projects you guys post here, nice work eberyone I really like the lowpoly world you've got going Jcorp, looks great[/QUOTE] Thank you!
[QUOTE=Jcorp;45597379]Thank you very much, and I have absolutely no idea! I had a few months away from uni studies, and as I only work part time I thought I'd start a project. My only goal is to make a game I like (I'm 19 and have been doing small games since I was 8, still hasn't happened yet!), so releasing it or selling it etc really hadn't occurred to me. Maybe if some people want me to, but I'm always paranoid about the quality of my work (for example steam early access makes my skin crawl) Thank you![/QUOTE] If you get at a point when you have a playable game and a lot of people would suggest you to try and release it you could try it on greenlite. About early access you can always look for some people that you might trust to help you with it without payment in case you decide to give it for free. I can say that people would help you with it for free because I would.(but I am not experienced enough(coding) for something like that)
For the past 2 days I've been looking for ways how to store the players name and score without being really easy to hack into or edit. For my world score I use php and mysql and for my personal score which should be stored on the client I tried to use list but after I start the game again they are gone. (Just rememberd I can also use the database and retrieve the score from the database with specific a specific name). Anyway in the future I want to update this game and I want it to make it more secure because I want to have money in the game which you use to buy things. What I am asking for is for tutorials/references/docs that could help me get a better understanding of how to secure it better.
[quote]personal score which should be stored on the client[/quote] You already have your database interfacing code in your game, why not just use that, even for personal score. If you still want personal score to be client side, have you looked at this video? [url]http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/persistence-data-saving-loading[/url]
[QUOTE=Pelf;45565540]I guess I just don't like players being able to easily edit and cheat their saves. And it seems common practice to save games in a filetype that notepad can't edit. Maybe I shouldn't concern myself with what players do with their saves.[/QUOTE] I use [url=http://msdn.microsoft.com/en-us/library/system.io.binarywriter(v=vs.110).aspx]System.IO.BinaryWriter[/url] myself. Though nothing is impervious to modification, using a binary format does make it more of a challenge. Maybe enough of a challenge to deter it altogether.
How could I update my current prefab? I did tried something but the result is not the one I expected. [code] *****PlayerController Script public int totalJumps; void Awake() { if (PlayerPrefs.GetInt("TotalJumps") <= 0) PlayerPrefs.SetInt("TotalJumps", 0); } *****Jump Script //Update the personal stats PlayerPrefs.SetInt("TotalJumps", PlayerPrefs.GetInt("TotalJumps") + playerController.totalJumps++); [/code] The output of this is. That is the result for pressing the button 5 times(the PlayerPrefs... is inside a button). [img]http://i.imgur.com/qlxNJei.jpg[/img] I am 100% sure the problem is with TotalJumps PlayerPrefs but not sure how else to do it.
Examine your logic more closely. Here's what's going on: I'll refer to PlayerPrefsTotalJumps as the value stored in PlayerPrefs, and ScriptTotalJumps as the value on your script. [code] PlayerPrefsTotalJumps: 0 ScriptTotalJumps: 0 [/code] So the player jumps, and this is the code you execute: [code] PlayerPrefsTotalJumps = PlayerPrefsTotalJumps + ScriptTotalJumps++; [/code] This evaluates to: [code] PlayerPrefsTotalJumps = 0 + (0++); [/code] Which simplifies to 0 + 1, so now: [code] PlayerPrefsTotalJumps: 1 ScriptTotalJumps: 1 [/code] So far so good. Now the player jumps again. [code] PlayerPrefsTotalJumps = PlayerPrefsTotalJumps + ScriptTotalJumps++; [/code] Here's where things go wrong. [code] PlayerPrefsTotalJumps = 1 + (1++) [/code] Which simplifies to: [code] PlayerPrefsTotalJumps = 1 + 2 [/code] And therefore: [code] PlayerPrefsTotalJumps = 3 [/code] What you need to do is store the value of PlayerPrefsTotalJumps on start (let's say you store this in InitialTotalJumps), and then just set to: [code] PlayerPrefsTotalJumps = InitialTotalJumps + ScriptTotalJumps;[/code]
TotalJumps = 0 totalJumps = 0 *player jumps* totalJumps++ (1) TotalJumps = TotalJumps (0) + totalJumps (1) result: 1 *player jumps* totalJumps++ (2) Totaljumps = TotalJumps(1) + totalJumps (2) result: 3 and so on... [b]Edit:[/b] What he said, too
Thank you boh for the reply. After I posted this it did make more sense and I got what you told me but still could figure it out but now I know how to do it, thanks again.
A while ago I found a tutorial on google on how to make a 2D side scrolling game and it would show the progress of the map. The problem is that I can't find it anymore, if anyone knows which one I am talking about could you send me the link. Thanks in advance,
Found it, in case anyone was wondering what it was ([url]http://www.unity3dstudent.com/2011/02/platformer-progress-bar/[/url]). [editline]6th August 2014[/editline] I am trying to make some sort of metric system(get the distance that the player has walked). I thought to use 1 block - 1 meter, the problem is that I've been thinking this through but couldn't figure out anything how to do it. Could someone help me a bit here?
I also think it would be a better idea to write the playerprefs when the level is done or every checkpoint or whatever, just not on every jump. If the game crashes, or the computer loses power or any other event where your game will be exited improperly, you will have a score that is not "complete". The player will have more jumps then he actually played. If that makes sense :P
Are there any decent free audio managers out there? I tried to make my own but a lot of times audio doesn't play. And I can't quite figure out how to handle looping sounds.
[QUOTE=Pelf;45608842]Are there any decent free audio managers out there? I tried to make my own but a lot of times audio doesn't play. And I can't quite figure out how to handle looping sounds.[/QUOTE] Look in assets store. Most of the "good" assets cost money :) Also try to read post of the author of "Papers Please" about the sound system in his new game - [url]http://forums.tigsource.com/index.php?topic=40832.msg1048725#msg1048725[/url] (really nice article)
Sorry, you need to Log In to post a reply to this thread.