|
nice okay, thx for tips! too many helpful ppl to quote- going to read up on dataclasses, half of this project is getting more comfortable with python beyond knocking together quick system automation scripts, so it seems like a perfect opportunityD34THROW posted:I didn't even think of using lists or tuples; last time I was parsing a dice roll, I passed it as "XdY+N" as a string, splitting on "d" and then splitting again on "+" or "-", similar to: my diceparse function splits by [d+-] and then replaces "" or a missing list element with [1,6,0] respectively so that "d20" is [1,20,0], "3d" is [3,6,0], etc it then splits by [0-9] and if the second element is a -, it multiplies the third element of the original by -1 later I want to expand on this and support notation like 2d20kh1 (keep highest 1, standard dnd advantage roll) but I'm moving on to sketching out other features before I come back to that e: yes technically it re.splits and actually I don't have a clue if that's more or less expensive than multiple vanilla splits
|
# ? Oct 5, 2021 03:51 |
|
|
# ? May 19, 2024 09:11 |
|
Peanut Butler posted:e: yes technically it re.splits and actually I don't have a clue if that's more or less expensive than multiple vanilla splits
|
# ? Oct 5, 2021 14:43 |
|
As someone who is forced to work with Javascript, I loathe string manipulation and avoid it as much as possible, regardless of performance considerations. Basically I'm saying don't write this in JS.
|
# ? Oct 5, 2021 16:24 |
|
I'm trying to develop a cover mechanic mimicking MGS3. I'm using Unity (2020.3), a Cinemachine Freelook camera and the new Input System. Directional Input is captured in a Vector2 when the movement event is broadcast. I would like when in cover and player maintains directional movement into cover: - Camera Direction is perpendicular to cover, player is idle - Camera Direction changes by -Y (rotating to player right), player starts moving left - Camera Direction changes by +Y (rotating to player left), player starts moving right - Player movement input changing to the direction of the wall after camera movement should return player to idle - Camera Direction returning to perpendicular view angle should return player to idle Movement should then also be influenced by directional input relative to the players facing. Relative directional input becoming parallel with cover should cause the player to exist cover. Efforts towards a solution My current implementation only works when the player is facing in either direction on the X axis. When in cover with a facing on the Y axis, movement (induced from either Camera or input) the player does move, but in the wrong direction. Code: code:
The Dot Product of Camera Direction and Player Right give potential movement in camera direction. What I'm falling short on determining is how to properly transform directional input, or if that's even the right approach. I don't think this is the right approach because movement isn't really caused by the Camera Direction in MGS3, it's caused by the effects Camera Direction has on directional input. code:
Which of these approaches seems most reasonable/cheaper to perform, or are my problems rooted in the fact both approaches are wrong?
|
# ? Oct 5, 2021 17:39 |
|
Assuming you're not deliberately making a Resident Evil callback by using unplayable tank controls, you should determine your absolute input by multiplying the controller input by the camera rotation, and not caring at all about the player rotation.
|
# ? Oct 6, 2021 00:43 |
|
Is there a simple way to replace a game object's geometry in Unity? For example, if I started something as a cube, can I easily swap it out with an asset from the store? EDIT: So that it keeps all the same scripts, associations, etc Gin_Rummy fucked around with this message at 01:14 on Oct 6, 2021 |
# ? Oct 6, 2021 01:07 |
|
Gin_Rummy posted:Is there a simple way to replace a game object's geometry in Unity? For example, if I started something as a cube, can I easily swap it out with an asset from the store? Yup. Load up blender, make a new model, export as an FBX, drag and drop into your project and replace the mesh in the mesh renderer component and you're done; you might need to play around with your settings so up is not down and right is not left and it isn't either tiny as a flea or the size of the titanic but you get the idea.
|
# ? Oct 6, 2021 01:12 |
|
Raenir Salazar posted:Yup. Load up blender, make a new model, export as an FBX, drag and drop into your project and replace the mesh in the mesh renderer component and you're done; you might need to play around with your settings so up is not down and right is not left and it isn't either tiny as a flea or the size of the titanic but you get the idea. It's the mesh filter component, but yeah, you can swap meshes in/out no problem.
|
# ? Oct 6, 2021 01:14 |
|
If only Blender wasn't the worst 3D modeling tool ever created I do have an asset I created in ProBuilder (as well as a janky one imported from Blender), but neither show up in my options on the mesh filter.
|
# ? Oct 6, 2021 01:54 |
|
Make sure you're trying to use the mesh. Blender objects generally get imported as a prefab that contains a mesh, so you have to open them up to access the mesh asset.
|
# ? Oct 6, 2021 03:43 |
|
Gin_Rummy posted:If only Blender wasn't the worst 3D modeling tool ever created
|
# ? Oct 6, 2021 07:56 |
|
Jabor posted:Assuming you're not deliberately making a Resident Evil callback by using unplayable tank controls, you should determine your absolute input by multiplying the controller input by the camera rotation, and not caring at all about the player rotation. It's not RE style movement, it's Metal Gear Solid style movement while in cover. The player is locked into movement along their local X axis. I figured it out eventually and the solution is to use the Dot Product of the input (multiplied by camera forward/right) and players transform.right. This gives movement along local X based on directional input and camera angle, a la Metal Gear Solid 3. There might be a shorter way to express the camera stuff, but this is the idea written minimally. code:
Dr. Poz fucked around with this message at 16:39 on Oct 6, 2021 |
# ? Oct 6, 2021 16:09 |
|
I have a probably dumb question. Kinda new to 3D transforms. Using Godot but that shouldn’t matter much as it doesn’t seem to offer a dedicated function for what I need and honestly I just wanna know how the math works. Say I have two objects: I can get the Euler (or Quat if that changes things) of each to get each ones rotation in game space or relative to the parent or whatever What I want is to measure “is the rotation of firstObject different from the rotation of secondObject by arbitrary amount” So if the-thing-that-determines-where-the-feet-should-go’s rotation is different enough from the thing-that-determines-where-the-character-is-aiming’s rotation, do a thing (in this case a little step animation to reset the feet so they aren’t backwards when spinning around) Is there a way to calculate this? All my searching comes up with “how to determine the angle from one Vector3 to another” which is not really helpful when what I really want to do is compare the rotations of the two regardless of where they are in the game space. Thanks in advance as always
|
# ? Oct 7, 2021 04:47 |
|
CH Science posted:I have a probably dumb question. Kinda new to 3D transforms. Using Godot but that shouldn’t matter much as it doesn’t seem to offer a dedicated function for what I need and honestly I just wanna know how the math works. acos(dot(normalize(vec1),normalize(vec2))) sounds right to me for that, but math isn’t my strong suit. e: to elaborate about, the dot product of two vectors is equal to the product of their lengths and the cosine of the angle between them. if the vectors are normalized, lengths are 1, so the dot product of two normalized vectors equals the cosine of the angle between them. chglcu fucked around with this message at 05:02 on Oct 7, 2021 |
# ? Oct 7, 2021 04:54 |
|
So inverse cosine of the dot product of the two? I will try that and report back. Thanks!
|
# ? Oct 7, 2021 05:00 |
|
CH Science posted:So inverse cosine of the dot product of the two? I will try that and report back. Thanks! yep, if the vectors are length 1, hence the normalize in what I posted. Can be skipped if they’re already unit length.
|
# ? Oct 7, 2021 05:03 |
|
As a side note, this is useful to know since it, for example, allows you to find what side of a plane a point is on or whether two vectors are facing toward or away from each other, just by checking the sign of the dot product.
|
# ? Oct 7, 2021 05:12 |
|
chglcu posted:As a side note, this is useful to know since it, for example, allows you to find what side of a plane a point is on or whether two vectors are facing toward or away from each other, just by checking the sign of the dot product. That’s… super useful, awesome.
|
# ? Oct 7, 2021 05:43 |
|
CH Science posted:That’s… super useful, awesome. Yeah, what the dot product actually represents is very useful to know, and something that game dev tutorials always gloss over in my experience. As someone who dropped out of school before stuff like that was covered it was really eye opening when someone actually bothered to mention it.
|
# ? Oct 7, 2021 06:13 |
|
Yep my experience exactly. Thanks
|
# ? Oct 7, 2021 06:25 |
|
roomforthetuna posted:In general the allocations (and eventual garbage collection) are the most expensive part of that kind of thing, so whichever one has fewer intermediate strings is probably best. But also, this seems like a completely unnecessary thing to worry about optimization on, it's not the sort of thing you're going to be doing hundreds of times per frame. yeah lol I'm starting to realize that most of my coding habits were formed on <12MHz machines python can get v slow on my netbook if it's doing graphical or ncurses displays but I think that's more a case of using a tool made for a different task
|
# ? Oct 7, 2021 14:18 |
|
Peanut Butler posted:yeah lol I'm starting to realize that most of my coding habits were formed on <12MHz machines
|
# ? Oct 7, 2021 14:33 |
|
giogadi posted:I recommend gamemath.com this is a very good link, thank you for posting it
|
# ? Oct 8, 2021 07:31 |
|
Alright, I've worked out some of the basics of this thing, enough to start a SQLite database and some rudimentary rules and gameplay flow. This may or may not become something more than a digital TCG, I'm picturing more of a Soda-Dungeo meets MtG sort of thing? Dropping the general abstract/flow here for comments and questions.quote:Project Caelina is the working name of a digital trading card game being developed by BlackRed Studios. It is based on a system wherein hero cards use equipment to attack the opponent's heroes and then commander, reducing their influence to zero in order to win the match. I'm also considering something like ignum/aquum/terrum/caelum/luxum/tenebrum for some sort of additional flavor. Thoughts? One more question - would it make more sense to have one SQLite database for each type of card or store the type as a field?
|
# ? Oct 11, 2021 20:16 |
|
roomforthetuna posted:I get it, I'm the same way. I'll do *0.5 rather than /2.0 just in case the compiler for the language I'm using doesn't optimize const-divides to equivalent const-multiplies because hey that saves 4 cycles or something. But I try to keep myself to only doing it in places where it's basically equivalent, rather than digging deep into decisions about using different libraries and APIs for the optimization of a thing that isn't actually performance-critical. Would there be any compilers these days that don't optimise that kind of thing standard?
|
# ? Oct 12, 2021 05:11 |
|
MikeJF posted:Would there be any compilers these days that don't optimise that kind of thing standard?
|
# ? Oct 12, 2021 12:34 |
|
Are there any good resources (video/blog/book etc) that go into how to implement rebindable controls in a sane manner? I have a very basic outline in my head i.e. OS layer "VKCode == `W`" -> translation layer "Keyboard.W" -> some assignment to abstract buttons somehow(?) "Character.MoveFoward.IsDown()", but I'm not thrilled about it, and I know this is a space that's already been explored.
|
# ? Oct 14, 2021 04:53 |
|
Killed By Death posted:Are there any good resources (video/blog/book etc) that go into how to implement rebindable controls in a sane manner? I have a very basic outline in my head i.e. OS layer "VKCode == `W`" -> translation layer "Keyboard.W" -> some assignment to abstract buttons somehow(?) "Character.MoveFoward.IsDown()", but I'm not thrilled about it, and I know this is a space that's already been explored. Define a list of actions the user can make. Have an event for each action. Trigger the event when a user configured key is pressed.
|
# ? Oct 14, 2021 05:18 |
|
leper khan posted:Define a list of actions the user can make. Have an event for each action. Trigger the event when a user configured key is pressed. This. One layer further would be defining a list of input events (key down, key up, axis change) and a list of actions, and have a double-blind mapping between them. That helps when you want to support an input system that isn't what you originally planned (keyboard/mouse to controller, touch controls, etc). Another thing to think about is different mappings: swapping the set of mappings based on what has input focus, gameplay vs. UI being the main use case.
|
# ? Oct 14, 2021 07:07 |
|
If you possibly can, find an asset that does input handling for you. I use Rewired in Unity and it was absolutely the right choice. Unity apparently has a new input layer now but I've heard it has some annoying edge cases. The nice thing about doing this, instead of rolling your own, is that the assets will have broader support for different kinds of input. For example, Rewired supports hundreds of different gamepads transparently, including niche console setups. Rewired also has support for input remapping out of the box -- there's a pre-made UI prefab you can customize that will show the player all of the input actions you've set up, with the ability to change what they're bound to. It's a decently complicated scene, and when I started working on customizing it, I realized there's a poo poo-ton of edge cases here if you want to do it right, so I'm very glad that someone else has already done the work for me. As for feeding inputs to your code, I wouldn't actually personally use the event system. I find it easier to have my code query the input layer for inputs during each update tick. In particular, I find that this makes it easier for me to shunt input to only the specific bits of code that are currently listening. I wrote a wrapper around Rewired that I call InputDirector, and any code that wants to be able to access input data first has to push itself onto a stack as a listener. Then when it queries for input, it has to pass itself along (e.g. InputDirector.GetButtonDown(this, InputDirector.FIRE)). InputDirector then looks at its stack to decide if that listener is currently allowed to receive input, and if it isn't, then it gets back "no input". This lets me do things like just leave the player controller running when the game is paused. The pause menu pushes itself as a blocking listener when it comes up, and the player simply stops getting input. Then when the user accesses the options menu from the pause menu, the options UI pushes itself, and the pause menu stops getting input. When the user backs out of these UIs, they pop themselves, and the layers underneath start getting input again. It's very easy to think about. Every once in awhile you'll get a situation where some code dismissed its UI but didn't stop listening for input, or something like that, but that's easy to fix.
|
# ? Oct 14, 2021 14:55 |
|
Quick DoTween question, since I think some people here use it - what's the best way to make an ordered sequence of tweens? AKA, do one tween, then when it's finished, do a second. I know there's DOTween.Sequence() but whenever I use that it seems to play everything on it at the same time, rather than waiting. This is how I have them set up:code:
|
# ? Oct 14, 2021 22:17 |
|
CodfishCartographer posted:Quick DoTween question, since I think some people here use it - what's the best way to make an ordered sequence of tweens? AKA, do one tween, then when it's finished, do a second. I know there's DOTween.Sequence() but whenever I use that it seems to play everything on it at the same time, rather than waiting. This is how I have them set up: You can just stick a callback function into an OnComplete like this: transform.DOMoveX(4,1).OnComplete(MyCallback);
|
# ? Oct 14, 2021 22:25 |
|
I have made some additional progress, after my initial proof of concept I have moved on to actually getting "what I want" from the thing. Here's a 1024 by 512 texture of """simplex""" noise. Apparently it isn't enough to simply use 3D noise if I want the noise to wrap around but ultimately I think while nice to have probably isn't necessary as we'll see. Noise: Falloff+Water Level mask applied and then a colour ramp to get the silhouettes: Tag yourselves, I'm the mini Westeros down by the bottom of the "New World" continent. I actually like these results so much I haven't implemented yet a means of blending them as currently that's a tad pointless, as I'll explain below. But I threw the two images into Paint.net and slapped on some contrast: The "mountains" might not be the best, I want to layer ontop some ridged noise or perturbed noise to try to get more natural looking ridge lines but in most applications that use ridged noise its in a 3D application and not one where the noise ends up being normalized... Simply multiplying the two noise height maps together doesn't give particularly visible results because simply multiplying two floats kinda results in an averaged result. An interesting procedural world gen challenge is since I want to first make this generate playable mods for the Paradox games, where would "Europe" be? How would we determine the best location algorithmically? Top left of the larger continent? Top right? Bottom left? Bottom-Bottom-Right? Might be too challenging a question for me to implement a solution. But if I am able to at least figure out how to divide up the landmass into zones its an interesting question to ponder. (With the height map applied, a good candidate for "Europe" might be the middle-left Gondor looking area which looks to be surrounded by protective mountains; "China" could be the top right which seems mainly hilly and less mountainy than the other areas. My next step which is to categorize the map's features such as the number and size of land and water masses I can just do on the original height map using my water level and fall off settings as part of the flood fill (scanline) calculation. Basic idea is islands or water inlets that are too small will be eliminated; I'll have a list of all land pixels divided into different lists and from there I will randomly generate points for my voronoi/delaney map. For Europa IV, there's 3200 or so land provinces, and then maybe 1,000 or so sea tiles, so assuming a generous upper bound of 4,500 tiles, and for a 8k by 4k texture map thats over 33,000,000 pixels; so considering 71% of the globe is covered by water, thats 10 million or so pixels, I think makes the average province 2,500 pixels in area with the average sea tile being 24,000 pixels. Islands in EU4 and other games can be quite small, so I think the cut off on which islands to eliminate might have to be quite small, like sub 100 pixels while also being sufficiently far from land such that it can't just be merged together.
|
# ? Oct 15, 2021 04:49 |
|
If you want to wrap just on one axis, I think you should be able to map the x,y position to their 3d position on a cylinder and use those as your noise inputs. The equations for this should be similar to texture mapping a cylinder. chglcu fucked around with this message at 04:58 on Oct 15, 2021 |
# ? Oct 15, 2021 04:53 |
|
chglcu posted:If you want to wrap just on one axis, I think you should be able to map the x,y position to their 3d position on a cylinder and use those as your noise inputs. Yeah I had found some psuedo code already for it but I'm applying a fall off mask to my map along both axis anyways so I didn't feel the need to go further: code I found: code:
|
# ? Oct 15, 2021 05:07 |
|
Anyone happen to know why this algorithm from Wikipedia for a scanline non-recursive floodfill doesn't seem to work?code:
x is 0 and x - 1 is -1 and so doesn't set anything on that first if/while block. 0 is not "less than" 0 so it doesn't do Add (x, x1-1, y-dy, -dy) to s, and x1 is of course not less than x2 so of course it doesn't do anything in the while x1 < x2 where the going from 0 to .... I would expect to happen along the x axis. I am assuming that when it says: Add (x, x, y, 1) to s Add (x, x, y - 1, -1) to s That given (x,y) which is (0,0) then it wants to enqueue: (0,0,0,1) and (0,0,-1,-1). With that "Remove an (x1, x2, y, dy) from s" means that a tuple of four elements the elements are named: x1 (first element), x2 (second element), y (3rd element), and dy (4th). So tracing through: let x = x1 means x is 0. (0,0) is Inside but x-1 is not. if x < x1: well 0 < 0 is false, so skip. while x1 < x2: 0 < 0 is also false, so skip. Nothing changes for the second element in the queue s and so nothing happens for another iteration. Then there's no elements left. Raenir Salazar fucked around with this message at 06:22 on Oct 18, 2021 |
# ? Oct 18, 2021 06:16 |
|
Well the wikipedia page mentions that their version "corrects some bugs in the original." It's quite possible the wikipedia version is buggy, and your analysis appears right to me on first read. Now, I was able to track down the supposedly buggy "original," maybe you'll find it helpful. ov = "old value", nv = "new value." If you do figure out what's wrong with that wikipedia code, be sure to mention it. I'd like to correct the article if possible. code:
Edit: Oh, it's assumed that the pop function adds dy to y. It's also assumed that the push function doesn't push if y+dy is out of bounds HappyHippo fucked around with this message at 23:05 on Oct 18, 2021 |
# ? Oct 18, 2021 22:28 |
|
Yeah someone just pointed out to me that version as well, mega-oof if its also buggy though. e: Just saw your edit, yay! Much rejoicing! e2: HappyHippo posted:code... I'm glad you took the time to write it out and format it better because in the link to the pdf the alignment of the code doesn't line up very well. That loop do while loop in particular isn't clear. e3: I just noticed but when it says "y + dy <= win.ymax" is the psuedocode 1 indexed instead of 0 indexed? Raenir Salazar fucked around with this message at 03:32 on Oct 19, 2021 |
# ? Oct 18, 2021 23:08 |
|
(Crossposted from the Making Games Megathread) I'm having some trouble with jitter in a cinematic I'm working on: https://i.imgur.com/SkIiu7g.mp4 First there's the shadow jitter, which you can see at the beginning as the camera pulls out. It is not affected by actual lighting settings -- I can bracket the shadow near and far planes precisely on the airplane, change the biases, etc. and it'll still flicker. It does go away entirely if I turn off the main camera's CinemachineBrain, but no setting I've changed on the virtual camera itself has affected the jitter. The virtual camera is using a Transposer body and Composer aim, and it's following an empty that has a CinemachineDollyCart on it, which is tracking a CinemachineSmoothPath in LateUpdate. The airplane is similar, using a dolly cart to follow a path in Update. The second is the jitter in the apparent movement of the airplanes. This is especially noticeable when they start their dives. I have no idea what's causing this. The camera's not moving much during this period, and the jitter's still visible even if I lock it in place. It feels like I'm dropping frames or something, but the editor reports that it's consistently staying well above 60FPS. Any ideas?
|
# ? Oct 19, 2021 19:35 |
|
|
# ? May 19, 2024 09:11 |
|
TooMuchAbstraction posted:(Crossposted from the Making Games Megathread) I don't know too much about that kind of graphics pipeline to be of help but I love the cinematic feel you're going for! I love that combination of like Star Wars, Star Fox and Ace Combat you're doing.
|
# ? Oct 19, 2021 20:21 |