|
You are adding to a float continuously? That will cause errors to build up. It might not matter now but your "time" will drift noticeably relative to real time.
|
# ? Jan 23, 2017 10:32 |
|
|
# ? Apr 26, 2024 22:36 |
DateTimes are structs so don't worry about instantiating new ones each update, its about as harmless as making new floats or what have you. I agree that adding a delta value every step seems odd, why not just have an initial DateTime that is saved and compare that against DateTime.Now? timeSinceLevelLoad = DateTime.Now - levelLoadTimeStamp will give you a TimeSpan which you use the TotalSeconds from or whatever.
|
|
# ? Jan 23, 2017 15:20 |
|
Yeah I guess I should just use a DateTime under the hood and work on that rather than using that float. For what I'm doing right now, it doesn't matter. After I forget what I did and use it later, then it will inevitably lead to something. I also suffered a little last night to try to persist some of the schedule I was doing. Say, I am trying to save some state that includes movement decisions. I have one dumb AI that just moves in one direction for a little bit, sometimes pauses, and may then move elsewhere. I had to save how long the component had waited and such, which is nontrivial when you're capturing absolute times. I am thinking I hit that magic moment where I should have a subsystem to handle that; it could persist all the timings for me in itself and keep all that gunk code out of my components.
|
# ? Jan 23, 2017 20:24 |
|
Does anyone know if it's possible to reverse the backface culling for Graphics.DrawMesh in Unity? I'm writing a 3D tilemap painter, and I want to be able to support flipped tiles that have a negative scale. However, unlike the MeshRenderer component, Graphics.DrawMesh doesn't automatically flip the backfacing if you pass in a transform with a negative scale. Since the meshes used for the tiles are reused a lot and can have custom materials, using a shader or inverting the mesh triangles would either kill performance or really limit functionality, so those options are out. GL.invertCulling seemed promising, but I don't know if/where I can call it since Graphics.DrawMesh doesn't draw immediately (And Graphics.DrawMeshNow won't render to the shadowmap, which I'd really prefer). Anyone have any ideas?
|
# ? Jan 24, 2017 08:49 |
|
Anyone have any suggestions on how to make a srpg ui manageable in Unity? Specifically the idea of: Click on Player -> Blue movement tiles appear around player -> Click on one of the tiles to move. My first attempt was this: 1. Player has a hittest, and MouseController monobehaviour attached. 2. OnClick MouseController spawns blue tiles around player. 3. Blue tiles have a monobehaviour called ClickState, and a 2d box collider. 4. When you click on one of the tiles a pathfinding code is used and it moves the player to whichever tile is clicked. The problem with this is I really don't like the idea of a nested prefab (the way it's set up is I have MouseController have public GameObject ClickState; and attached to it is the prefab ClickState with that code too). So I came up with this: 1. Player has a hittest, and MouseController monobehaviour attached. 2. OnClick MouseController searches the tiles around player according to the player's move and then activates the "clickable" state of the tiles that creatures aren't standing on. 3. The tiles in "clickable" state turn blue, and have a hittest and ClickState monobehaviour attached. 4. When you click the tile, it runs a pathfinding code and you walk to that area. 5. The tiles then go back to idle state, and the ClickState monobehaviour is removed. So with that current set up, I fear that having multiple code in different areas becoming unmanageable/hard to debug. I thought of another solution: 1. Player still has a hittest, and the MouseController monobehaviour attached. 2. The MouseController grabs all nearby tiles based on Player's movement. 3. OnClick MouseController creates a grid around your cursor, remembers your cursors coordinates, and knows where you are by comparing your cursors x,y to the grids x,y. 4. The MouseController tells the tile to change to blue when you position your mouse over the correct x,y coordinates. 5. When you click it runs a pathfinding code based on your grid position. 6. You move there. This way at least it's all from one source. I guess what I'm asking is if there is any good way to approach srpg like menus? Are either of these ideas on the right track?
|
# ? Jan 25, 2017 09:08 |
|
I am having trouble finding details of an algorithm to use so some advice would be helpful, 1) I want to make a 64x64 grid with a possible height from 0 to 6 with no adjacent point more than 1 different from the other (ie like populous original map look) 2) i then want to render it on screen in a Populous style isometric view, I am using LWJGL and java.
|
# ? Jan 25, 2017 11:19 |
|
Nude posted:Anyone have any suggestions on how to make a srpg ui manageable in Unity? Specifically the idea of: Click on Player -> Blue movement tiles appear around player -> Click on one of the tiles to move. I would handle everything but the I/O in code. Set up a structure to hold your map. An interface that takes as input a location and unit type and spits out a list of tiles. Pass that to some handler that notifies your UI to display. I definitely wouldn't try to mix the handling of my input with my system logic. Parse it into something useful and ferry it along to the underlying systems.
|
# ? Jan 25, 2017 13:17 |
|
TheresaJayne posted:I am having trouble finding details of an algorithm to use so some advice would be helpful, I'm confused as to what you need help with. Grid thing just adjust adjacent tiles when you adjust a tile? Isometric rendering has been covered in roughly 7 billion blog posts it feels like. Short version is render things in depth order.
|
# ? Jan 25, 2017 13:24 |
|
TheresaJayne posted:I am having trouble finding details of an algorithm to use so some advice would be helpful, I would assume a basic height map will get you the terrain, and then you adjust the projection (glOrtho?) assuming you do not want farther objects to look smaller.
|
# ? Jan 25, 2017 14:16 |
|
Rocko Bonaparte posted:I would assume a basic height map will get you the terrain, and then you adjust the projection (glOrtho?) assuming you do not want farther objects to look smaller. I was looking for an algorithm to generate a random map and then some links to how to render it
|
# ? Jan 25, 2017 14:35 |
|
TheresaJayne posted:I was looking for an algorithm to generate a random map I did have a sense there was more to it. If you're only giving something like six height levels then just about everything is overkill. The first thing I thought of was plasma fractals, which I remember seeing in the 90s. Then you probably want a texture atlas to deal with the coastline. I don't normally toy with projection so I can't account for most of the ways out there, but it seems to come down to either using glOrtho or how you toy with gluLookAt in particular. Are you trying to avoid using 3d libraries or something?
|
# ? Jan 25, 2017 15:58 |
|
TheresaJayne posted:I was looking for an algorithm to generate a random map TheresaJayne posted:and then some links to how to render it I think you can always split each square plaquette of 4 neighbouring points conforming to the |∆ z| <= 1 rule into two triangles which you then render. There are two ways of doing the split: code:
e: actually both ways of doing the split are possible for every z configuration, I forget how Populous does it. Herman Merman fucked around with this message at 16:35 on Jan 25, 2017 |
# ? Jan 25, 2017 16:04 |
|
Another option would be to use the Populous land raising/lowering mechanic, i.e. start with a flat map and the raise/lower the ground by a random amount at n random spots, enforcing the |∆z|<=1 between neighbours rule during each z change.
|
# ? Jan 25, 2017 16:13 |
|
leper khan posted:I would handle everything but the I/O in code. Set up a structure to hold your map. An interface that takes as input a location and unit type and spits out a list of tiles. Pass that to some handler that notifies your UI to display. I guess where I'm a little confused is how do I handle input without touching the system logic, am I misunderstanding what system logic/mixing means?
|
# ? Jan 25, 2017 20:36 |
|
Nude posted:Thank you for the help, I just want to make sure I understood this correctly. From what I understand you are saying: separate the user interface code from the rest of the code. Then set up another file that waits for input, grabs the map data, and spits out a list of tiles in relation to the character. Then the handler sees this list and weeds out any of the tiles you can't walk on. This is passed to the user interface code. The ui code then displays the tiles and also has the code for when you click you move there? You want them to be disconnect in as much as you can, eg, switch from mouse control to joystick control, and not change your logic at all. So, instead of OnMouseClick handling everything, you have OnMouseClick figure out which tile you're clicking on, and then call the SelectTile function or whatever, which affects the gamestate in a way that's agnostic of the input method. If you don't follow this sort of practice, you get strange issues where if you want to, eg, make it so that clicking on tiles does something different while in a different game state, you'll end up with all these weird issues that cascade through everything, as your logic is so intertwined. Whereas, if you have a layer of abstraction between input and logic, you can just cleanly slot in that check. It's just easier in general to make changes and find bugs when any given piece of code is concerned with as little as possible.
|
# ? Jan 25, 2017 21:17 |
|
Working on flying enemies for a defense game in Unity. Unity's built in navigation system is based on walking, but do I need to have a navigation volume for a flying enemy that just needs to fly to the target point? I think a simple steering behavior would do well enough, instead of adding in a beefier navigation package that can handle volumes, such as an A* package.
|
# ? Jan 26, 2017 21:21 |
|
BirdOfPlay posted:Working on flying enemies for a defense game in Unity. Unity's built in navigation system is based on walking, but do I need to have a navigation volume for a flying enemy that just needs to fly to the target point? I think a simple steering behavior would do well enough, instead of adding in a beefier navigation package that can handle volumes, such as an A* package. Is there a reason the enemy needs to be dodging vertically? I.E. do they need to fly under arches, over hills? or could you just use the normal navmesh, and adjust the Y yourself/set it and leave it?
|
# ? Jan 27, 2017 01:06 |
|
I downloaded the Smash 4 Captain Falcon model from here and have been making things with it when I need a little pick me up. https://www.youtube.com/watch?v=jvxqKyEschE
|
# ? Jan 27, 2017 02:35 |
|
How can I create a normal map at runtime in Unity? No matter what I do, things look messed up. Fairly inconspicuous normal map: Sphere looks really weird. Edit: Nevermind, I was converting B to B*2-1 instead of just the R and G channels. Elentor fucked around with this message at 04:40 on Jan 27, 2017 |
# ? Jan 27, 2017 03:48 |
|
Alright, hopefully this thread has some folk in it who can give me fresh perspectives on this. So we're getting close to launch on Sumer--the one big thing that's remaining is online multiplayer. I've been using UNET, and have hit the point where it...pretty much works. Most of the easily replicatible bugs have been fixed, and it's pretty common to be able to get through a full 15 minute game without any bugs or desyncing popping up. However, that's obviously not good enough--there's still this whole class of bug that can pop up when two mutually exclusive events happen too close to each other and things can start to desync in a way that's hard to come back from; I have safeguards against this already built in, but the time delays inherent in online multiplayer means that new ways for things to break are constantly popping up. Additionally, there are a few situations where I want a player to have immediate feedback that they're performing an action once they send the input (because anything else just has bad gamefeel), but where there's a chance that the action will turn out to be invalid due to another player's action--how do people handle retroactively rolling back a player's action? It seems like most methods I could use to do that would end up just allowing for even more hard to replicate desyncs where the rollback could roll back into an incorrect state due to the gamestate changing in the in-between time. These feel like that kind of annoying issue where it's too specialized and tied to the details of your game to be too easy to find info on, while still being the type of wheel I shouldn't be trying to reinvent from scratch. I can definitely think of some ways I could handle these issues (fundamentally rewrite the entire back end of the game so that the model and view are two completely distinct things and then just be really aggressive about keeping the models synced constantly), but I'm really hoping there are ways of doing this that feel less like remaking the entire game from scratch.
|
# ? Jan 27, 2017 09:06 |
|
OtspIII posted:Alright, hopefully this thread has some folk in it who can give me fresh perspectives on this. I've always written netcode myself; never really trusted unet, as I don't have any way to address any bugs in it. The short version is it depends on the game. For faster paced games, I've just synchronized game state between the session host and clients; allowing visual state to vary from network state but aligning visual state to network state over time. For slower games, I've handled it by synchronizing inputs over time and rerunning the sim as new inputs come in. It's not a small amount of work, but I (and my clients/employers) have been happy with the results.
|
# ? Jan 27, 2017 11:27 |
Does anyone here have any experience with ImGui? I'm using it to build my debug system, and was wondering if there was a way to create a scrollable multiline textbox for console output that isn't editable?
|
|
# ? Jan 28, 2017 08:04 |
|
I'm sure this gets asked all the time but gently caress it. I have a few years of professional c# experience under my belt and I want to get into unity coding in my spare time, ostensibly to build a hipster 2d platformer. Are there any good starting points out there you can recommend? The are a million tutorials but hard to wade through everything. I have a pluralsight sub if that helps.
|
# ? Jan 28, 2017 08:30 |
|
Plavski posted:I'm sure this gets asked all the time but gently caress it. I have a few years of professional c# experience under my belt and I want to get into unity coding in my spare time, ostensibly to build a hipster 2d platformer. Are there any good starting points out there you can recommend? The are a million tutorials but hard to wade through everything. I have a pluralsight sub if that helps. Imho the best way is to start a new 2D Unity project and start messing around. Maybe start with a square for your hero and a platform. Then add controls for your hero. Keep googling and building from there.
|
# ? Jan 28, 2017 19:47 |
|
Plavski posted:I'm sure this gets asked all the time but gently caress it. I have a few years of professional c# experience under my belt and I want to get into unity coding in my spare time, ostensibly to build a hipster 2d platformer. Are there any good starting points out there you can recommend? The are a million tutorials but hard to wade through everything. I have a pluralsight sub if that helps. https://github.com/prime31/CharacterController2D http://cjkimberlin.com/project/PC2D.html And if you want to buy something this started as an asset flip of the first link but has been rebuilt as its own thing: https://www.assetstore.unity3d.com/en/#!/content/26617 PRO TIP: don't use "real" physics for a platformer unless you're going for a very specific feel.
|
# ? Jan 28, 2017 20:20 |
|
Joda posted:Does anyone here have any experience with ImGui? I'm using it to build my debug system, and was wondering if there was a way to create a scrollable multiline textbox for console output that isn't editable? https://docs.unity3d.com/ScriptReference/GUI-enabled.html
|
# ? Jan 29, 2017 18:51 |
Thanks, but this is Unity's GUI system, not ImGui.
|
|
# ? Jan 30, 2017 04:17 |
|
leper khan posted:I've always written netcode myself; never really trusted unet, as I don't have any way to address any bugs in it. How much do you do yourself? Do you not even use their network transforms or their sync card? What's the lowest level code that you write in unity? Are you just making calls to open sockets and writing bytes to them or what? I tried relying on unity's syncvars and following the clues I got from a description by valve on how their implemented networkin in source... It only ended in incredible frustration.
|
# ? Jan 30, 2017 06:24 |
|
oliveoil posted:How much do you do yourself? Do you not even use their network transforms or their sync card? What's the lowest level code that you write in unity? Are you just making calls to open sockets and writing bytes to them or what? Yeah, I've written libraries to abstract state synchronization in .net 3.5 C#. They reflect over POD types such that I pass a struct in as a template argument and it encodes things to a binary format. It mostly handles the details behind the scenes for applications. It's been working very well, and I'm happy with the results. E: To answer your questions directly: All of it. No. The library is independent of Unity. The unity applications will see something like net.Send(gamestate) and also listen to an event that's similar. I wrote the full implementation of that, but it's not exposed to the clients at a low level. That does happen eventually, yes. It's abstracted from the user.. leper khan fucked around with this message at 07:05 on Jan 30, 2017 |
# ? Jan 30, 2017 06:38 |
|
Joda posted:Thanks, but this is Unity's GUI system, not ImGui. That's confusing because unity's inbuilt UI system is called IMGUI also Sorry! https://docs.unity3d.com/Manual/GUIScriptingGuide.html
|
# ? Jan 31, 2017 19:12 |
Strumpy posted:That's confusing because unity's inbuilt UI system is called IMGUI also Sorry! Oh, I didn't know that. Full name of what I'm using is dear imgui, but I thought it was the only GUI library whose name actually included imgui (and the creator himself even refers to it by that name. Only added the dear because imgui is a design paradigm.)
|
|
# ? Jan 31, 2017 19:34 |
|
I just realized I am setting up an event system in Unity that may call back to a dead object. I am scheduling fairly routine events to fire off in the future for stuff like mobs, and the mob could get killed before the event fired. Can I null check for stuff like that? My fallback is notifying the subsystem each time the object will be destroyed, which means the queue in the subsystem gets iterated to cull any events on that object.
|
# ? Feb 2, 2017 07:04 |
|
If the dead object you're talking about is registered to a default C# event, the event itself will be keeping the object alive via strong reference as long as the event source is alive. If that's a problem, you can either try implementing weak events or write your code to more explicitly manage references and event (de)registration. In the case of a mob dying, you know at least one point in your object's lifetime when it needs to clear all references to itself so it may make sense to give it or its managing object access to deregistration methods at that point. Just be careful to avoid creating lasting circular references when giving access to those deregistration methods, that can get bad pretty quickly. And be careful to account for other circumstances where you'd want your object to go away, like during scene changes. If something somewhere up the reference chain sticks around then so will all its references, and their references, etc. If your object is registered to a Unity event, you don't have to worry about the event keeping the object from being garbage collected because Unity uses weak references to store registered listeners and nothing will be called on or passed to the object once all other references are cleared (if it's a monobehavior then you'll also need to call Destroy on it or its game object).
|
# ? Feb 2, 2017 19:14 |
|
We are continuing our efforts to create a kind of sports game, but have been having a lot of issues simply getting the 'feel' of hitting the ball to be just right. We aren't exactly sure how to do this, our best effort has been to create an empty game object and tried to apply a forces from that. Are we approaching this in the wrong way entirely? We can't seem to find any tutorials that are doing what we are doing, even though we know that it's possible.
|
# ? Feb 2, 2017 22:29 |
|
Doctor Soup posted:If your object is registered to a Unity event, you don't have to worry about the event keeping the object from being garbage collected because Unity uses weak references to store registered listeners and nothing will be called on or passed to the object once all other references are cleared (if it's a monobehavior then you'll also need to call Destroy on it or its game object). That being said, you can destroy UnityEngine.Object by calling destroy and the UnityEvent will clean that out (as we can check if the native side has been destroyed). Under the hood though, implicit weak references are not used.
|
# ? Feb 3, 2017 01:15 |
|
Rocko Bonaparte posted:I just realized I am setting up an event system in Unity that may call back to a dead object. I am scheduling fairly routine events to fire off in the future for stuff like mobs, and the mob could get killed before the event fired. Can I null check for stuff like that? My fallback is notifying the subsystem each time the object will be destroyed, which means the queue in the subsystem gets iterated to cull any events on that object. I'd recommend the null-checks, even if you're culling them as they die. I had a project where I was actively culling events/deregistering them and still ended up a hard to track down bug causing NullReferenceExceptions in my callback. It was solved by something like this at the start of the callback: code:
|
# ? Feb 3, 2017 01:27 |
|
BirdOfPlay posted:Fun fact: Unity purposely overloaded the null check to include cases of the attached GameObject being in the Destroyed state, so that it plays nicely with the managed side of the engine. See here for an explanation about it. One of the dumbest things the engine does imo.
|
# ? Feb 3, 2017 01:42 |
|
Welcome to GBS posted:We are continuing our efforts to create a kind of sports game, but have been having a lot of issues simply getting the 'feel' of hitting the ball to be just right. We aren't exactly sure how to do this, our best effort has been to create an empty game object and tried to apply a forces from that. Are we approaching this in the wrong way entirely? We can't seem to find any tutorials that are doing what we are doing, even though we know that it's possible.
|
# ? Feb 3, 2017 02:19 |
|
roomforthetuna posted:Using a generic physics engine for a sportball game is likely to result in a lovely experience, in much the same way as using generic physics for a platformer does. Not quite as serious as platforming, but you're still going to have to inject all sorts of tweaks and fakes to make a ball behave in a fun way. We had considered trying to make something in Source or in Unreal, but we found by far the most information about how to make things Unity. We are mostly trying to get a working concept going to spur some interest in the idea. At this point I just want to be able to do simple actions with the ball so we could simulate basic gameplay. We are struggling to get to even that point because we are novice programmers.
|
# ? Feb 3, 2017 02:55 |
|
|
# ? Apr 26, 2024 22:36 |
|
Strumpy posted:This isn't true (I literally wrote the feature). When the system was being designed the idea was toyed with but abandoned due to the fact that they are generally used to mange UnityEngine.Object refs. Under the hood it uses normal delegates. Oh whoops, count me as misinformed then. I was looking into weak events recently and came across a post by a moderator on the Unity forums saying they used weak references so I just assumed that's how they worked. Thanks for the clarification. Also my team's level designers are in love with Unity Events and by extension you.
|
# ? Feb 3, 2017 04:12 |