• Unity3D - Discussion
    5,004 replies, posted
[QUOTE=garry;40276746]But when I need it can't I just add it? It seems to make more sense than adding it to everything on the off chance of needing it? With the serialization thing.. if I rename a variable, or change it from a bool to an int.. how would the serialization stuff handle that? Would it be able to load old saves still?[/QUOTE] If you were really concerned with versioning have you looked at protobuf-net? It uses attributes and you can create a full backward and forward compatible class that can be serialized. Or you can write a .proto and use the C# generator from protobuf-net meaning the saves could be read in anything with protobuf libraries.
[QUOTE=secundus;40277853]Is your game first person? Why not having all player input in one place rather than scattered across all scripts, like a PlayerController or something? With that you can have something like: YourPlayerController.cs [CODE]code[/CODE] And then your Door.cs have something like this: [CODE]code[/CODE] EDIT: Wow took me so long to reply until you figured it out yourself.[/QUOTE] I was thinking of doing that before but I figured I would get it into a working state first. I also noticed that the way I had it before (the input and raycasts in the door.cs) meant that every time I pressed the use key, it would do a raycast for every door in the level. :v: [editline]edit[/editline] also, I'm only using the Input Manager for mouse movement and mouse wheel because I heard that the input manger can't be edited in script, and thus you can't change controls ingame, only in the launch window thing. Instead I have a ProgramSettings.cs that keeps track of all inputs so that the key bindings can be changed ingame. My key binding and other control variables look like this: [CODE]//==================// Mouse Settings //========================// public static float mouseSensitivityX = 4.0f; public static float mouseSensitivityY = 4.0f; public static float mouseWheelSensitivity = 1.0f; public static int mouseYInversion = 1; public static int mouseXInversion = 1; //==================// FPS Key Bindings //======================// public static KeyCode keyForward; // KeyCode.W public static KeyCode keyBackward = KeyCode.S; public static KeyCode keyLeft = KeyCode.A; public static KeyCode keyRight = KeyCode.D; public static KeyCode keyJump = KeyCode.Space; public static KeyCode keyCrouch = KeyCode.LeftControl; public static KeyCode keySprint = KeyCode.LeftShift; public static KeyCode keyUse = KeyCode.E;[/CODE] and to get the key I just type Input.GetKey(ProgramSettings.someKey). For now, the keys are defined in code (except FPS keyForward which I was using to test key loading) but sooner or later they will all be loaded on startup or when the player changes them in the Options screen.
[QUOTE=SteveUK;40276735]It might be pointless until you actually need one. It's always worth considering what's available to you. And with the built in version tolerant serialisation, I imagine you're just duplicating work since you can set the version the property was added, and you can tell it what to ignore. It's a feature that's already there and so far looks like you're replicating it.[/QUOTE] In the end if he wanted to change how a variable is retrieved he could use the variable getter/setter. Also, for serialization, using seralizer libraries is generally a bad idea as they take up a lot of data compared to you making your own implementation. However, proto-buf is a good example of a way to make a good data storage thats cross compatible.
Is it bad to put physics calculations in Update() instead of FixedUpdate()? My zero gravity player controller uses FixedUpdate() for movement since the player hull is a rigidbody but in low framerate situations the movement is completely screwy since the movement is fixed but frame updating isn't.
Putting physics calculation in Update() wouldn't give consistent result, as the number of Update() calls vary according to your framerate. FixedUpdate() has a default of 50 updates per second. [url=http://answers.unity3d.com/questions/10993/whats-the-difference-between-update-and-fixedupdat.html]Better explanation here[/url] Not-so-fun-fact: FixedUpdate() is affected by Time.timeScale, so a Time.timeScale of 0.5 will make FixedUpdate() to only update 25 times per second, while Time.timeScale of 2 will make it update 100 times per second. You can change the interval of FixedUpdate() by altering Time.fixedDeltaTime, usually being Time.fixedDeltaTime = 0.02 * Time.timeScale.
So should user input be done once per frame, or in the fixedupdate?
[QUOTE=Richy19;40278523]So should user input be done once per frame, or in the fixedupdate?[/QUOTE] You can take user input as often as you like, but if it's affecting physics it won't have any effect until the next fixedupdate
[QUOTE=ben1066;40277933]If you were really concerned with versioning have you looked at protobuf-net? It uses attributes and you can create a full backward and forward compatible class that can be serialized. Or you can write a .proto and use the C# generator from protobuf-net meaning the saves could be read in anything with protobuf libraries.[/QUOTE] I did consider it, but I worried that it was getting too heavy for something that should be really simple :(
Why do I get this issue when a spot light aims towards a point light? I have my assumptions on the blending mode, but I'm not certain. [media]http://www.youtube.com/watch?v=8vgLQFDuthA[/media]
Unity limits the number of pixel light being rendered at one time when using Forward rendering. When this limit is reached, all other pixel lights are rendered as vertex light instead. This amount can be changed in Edit > Project Settings > Quality. Other way to fix this is to switch to Deferred rendering in your Main Camera; it can render many pixel lights, but only available in Pro.
[QUOTE=secundus;40283719]Unity limits the number of pixel light being rendered at one time when using Forward rendering. When this limit is reached, all other pixel lights are rendered as vertex light instead. This amount can be changed in Edit > Project Settings > Quality. Other way to fix this is to switch to Deferred rendering in your Main Camera; it can render many pixel lights, but only available in Pro.[/QUOTE] Thanks, changed to four from two and works perfectly.
[QUOTE=garry;40276645]So you should do that just so you can make them protected/private? I understand why people would want to do that (although I think it's just making work for yourself). The reason I made them public was I wanted them to show up in the editor, like this: [img]http://i.imm.io/12RH0.png[/img] Does your method keep that rocking? Yeah I saw the serialization stuff. I decided against it, and to do it in a low level straight forward way - because I could see a lot of ways that system could end up fucking me in the ass.[/QUOTE] If you want variables to show up in the inspector, you should set the inspector to debug mode, this should show you all variables that exist in the script. [img]http://puu.sh/2AO2J[/img] Click the thing on the right and set it to 'debug'.
[QUOTE=FalconKrunch;40293790]If you want variables to show up in the inspector, you should set the inspector to debug mode, this should show you all variables that exist in the script. [img]http://puu.sh/2AO2J[/img] Click the thing on the right and set it to 'debug'.[/QUOTE] Yeah but I want to edit them ?
Made a post processing shader last night. Well. Tried. [img]http://i.imm.io/130Rq.png[/img] That code makes this happen: [img]http://i.imm.io/130Rs.png[/img] but if I remove the comments this happens: [img]http://i.imm.io/130RE.png[/img] I figure it's some kind of crazy optimization in the shader compiling?
[QUOTE=garry;40300077]Made a post processing shader last night. Well. Tried. [img]http://i.imm.io/130Rq.png[/img] That code makes this happen: [img]http://i.imm.io/130Rs.png[/img] but if I remove the comments this happens: [img]http://i.imm.io/130RE.png[/img] I figure it's some kind of crazy optimization in the shader compiling?[/QUOTE] Looks like its optimising out colG because it's unused and setting colR to colG, but obviously colR.r shouldn't be set to colG.r (which it seems to be doing incorrectly) It does look like a bug from here Also the second case (as you probably worked out) looks like its actually the correct case (though I'm not a shader man, so i could be wrong)
Yeah the second one is how I would expect the first one to render [editline]16th April 2013[/editline] Is NGUI really the best GUI system for Unity right now?
Yeah, if you're skeptical, they do have an [url=http://www.tasharen.com/get.php?file=NGUI]evaluation version[/url] that you can try before purchasing it.
NGUI is nice in the limited use I've had with it, but between it and the standard unity gui system its much better. Keep in mind it is a bit of a pain in the ass to get working properly with custom assets though since you have to mess around with texture atlases and bitmap fonts, unless thats changed since I've used it.
Garry I'm not sure if its been asked before but. Are you using the pro version of Unity or the lite? Some of those shadows look really nice.
[QUOTE=sarge997;40303158]Garry I'm not sure if its been asked before but. Are you using the pro version of Unity or the lite? Some of those shadows look really nice.[/QUOTE] He is using the Pro version. Word on the street is the next Facepunch Studios game is being built on Unity, so yeah - pro version is the only way to go for what I imagine is a commercial project.
I'm having a pretty major problem. I have one giant .png which is the level, and a similar one for each layer of parallax. I also have access to the 2D Toolkit, if useful. I need to make this giant .png into the level. How would I best go about doing it? If I paste it on a plane, how can I get the scale exactly right? Would it be possible for me to draw a polygonal collider on it? [editline]16th April 2013[/editline] I'd be very grateful if I can get some help tonight.
NGUI works for things like 99% of the time. But when you're trying to make a panel show using a 3D camera.. and the layers won't stay on top of each other because they're using the bounding box of the game object and the only way to make it come in front is to pull it near the camera.. it annoys the shit out of you. The font rendering really seems ass backwards too. I get why it does it like this. It wants to be fast. Totally understand. But these bitmap generated fonts never seem to look as good as the TTF rendered fonts that the onGUI stuff produces.
[QUOTE=Asgard;40303932]I'm having a pretty major problem. I have one giant .png which is the level, and a similar one for each layer of parallax. I also have access to the 2D Toolkit, if useful. I need to make this giant .png into the level. How would I best go about doing it? If I paste it on a plane, how can I get the scale exactly right? Would it be possible for me to draw a polygonal collider on it? [editline]16th April 2013[/editline] I'd be very grateful if I can get some help tonight.[/QUOTE] I think you'd have to just lay out the plane and then scale the texture to fit it. That's the only way I can imagine to do it.
In the end I fixed it by using a orthographic camera with half the size of the target resolution, which makes 1 unit == 1 pixel.
My terrible font kerning battle is over. [img]http://i.imm.io/13eLX.png[/img] This is NGUI with this: [url]http://www.tasharen.com/forum/index.php?topic=3749.0[/url]
Is it possible to change the lightmapping tool to use the GPU to bake lightmaps? [editline]18th April 2013[/editline] snip: [url=http://answers.unity3d.com/questions/35050/argumentexception-gettime-can-only-be-called-from.html]fixed it[/url]
Can anyone please help me out here? If i used baked lightmaps, smoothing on objects looks fine but normal maps don't work. If i use real time point lights the smoothing is rigid and horrible on objects but bump maps work. If i use both simultaneously there's still rigid edges but normal maps work. Is there a way I can make object shadowing smoother with real time lights or make bump maps and specular shaders work with baked lighting?
I'm using the free version so i'm stuck with forward rendering
More time spent fighting NGUI to make it work how I want. Decided to stop resisting and use it how they want me to.
Made a game tonight. You need to wait until the clock strikes before you can shoot. [url]https://dl.dropboxusercontent.com/u/3590255/Tests/Approval/7458754/full.html[/url]
Sorry, you need to Log In to post a reply to this thread.