text:
Keeping a game from getting boring once you have everything?
I'm making a sims-clone, as I've said numerous times already. I'm not slavishly re-creating any one of the games (though I often feel like I have to at times for practical reasons, on a side note designing this thing I've actually gained a deeper understanding as to why The Sims 2 worked the way it did).
Possibly one of the biggest problems these games have is that things get boring once you have everything. When you start off, you're playing fully adult characters who don't have a single damned skill or anything other than enough money to build a starter house. Getting to the top is quite an effort. However, once you're there you're so swimming in cash the whole thing becomes a joke. You also have all the best items in the game now too, and any other characters born during gameplay have almost the equivalent of an adult's life span before they become an adult themselves. This combined with all the best furniture items being already present for them means they can easily build themselves up far faster than the founding generation can.
I've thought of several ways to fix this, but I'm not sure if they would be sufficient. Here are my ideas:

Once you're wealthy, there's nothing that can bring you down. Living expenses are trivial even at the beginning of the game. Even if you made no money at all, after the first generation dies you can easily survive without any other character making a single penny their entire lives for several generations before the funds the founders built up runs out. The solution to this would be to increase the cost of living. If you have a mansion, you're going to need multiple characters at the highest tier of their career paths to pay the taxes on it. If someone isn't pulling their weight, everyone's going down. The repoman is going to be taking your stuff, you're going to struggle to buy food, your characters are going to be unhappy about not being able to buy the stuff they want. So higher taxes, and maybe higher food costs. If you have the lowest wage possible, you should only be able to pay the taxes on a minimalistic shack that only has the bare necessities. No fancy house, no expensive items. Not even enough to support a family. You want to move up in the world, you gotta be making more.

As mentioned, another problem is the items. Items that help build skills come in over a dozen tiers, each one being progressively better at building a specific skill. Once these are all present, building skills becomes trivial. Even then, once you have all the expensive items, your sims are never going to roll wants to buy more. The solution to this would be to make items have a finite lifespan. Those dinner chairs the founder bought aren't going to still be usable after 10 whole generations. At best, items should give out by the time the grandchildren come of age, meaning they at least will have to build back up themselves. More expensive items should last longer of course, but nothing lasts forever. This includes items such as career rewards which are far harder to get; unless you have multiple characters in the same career track, you're never going to get multiples of them.

Increase the time to takes to build skills. As-is, you can easily max all the skills before you grow old even if you start as a full-grown adult. Something like that should take one's entire lifetime. Also, such a character would probably have to stay out of work so they would have enough time to build up all these skills. For practicality though, a fully adult sim should still be able to reach the top of their career before their time comes, but of course that normally doesn't require one to max all the skills and get every 'power' in the game. To fix adult characters, some sort of system should be implement to make them have skills and friendships as if they actually did have a life prior to the game's start. Then the game can easily be balanced without making it impossible for pre-made adults to achieve their dreams.

Discourage wealth-building. Even if you do want to just lay back and live off your inheritance, its hard to do that. Sims have a feature called 'lifetime wants', which is simply an ultimate goal they want to achieve. Problem is, its rare for this to not be 'reach the top of x career'. Fortune sims in particular just want to make money by any means possible. The particular curiosity is knowledge sims. They're supposed to want to learn things, but outside of 'max all skills', all their possible lifetime wants are just 'reach top of x career'. In fact, they have far more of these than even fortune sims do! If you aren't making money, its hard to keep your sims happy. Wealth doesn't buy happiness; simply having a giant house full of expensive stuff isn't actually going to do much for your sims' moods unless they really like to build skills. Even then, all skills can only be maxed once, so once that's done it can be really hard to keep a knowledge sim happy. They just fall into a cycle of wanting to witness the paranormal, which is not a common occurrence. Its okay for fortune sims to want to become a boss all the time, but it shouldn't be the norm for everyone else. Popularity sims should want jobs with short hours so they can spend more time socializing. Knowledge sims should want this so they can spend more time studying. Family sims should want to stay home and interact with their family. Romance sims should want the same thing popularity sims do in terms of jobs. Pleasure sims should also prefer to party than work. Everyone other than the fortune sims shouldn't be a workaholic. This however would require the addition of far more stuff to accomplish. Like I said, knowledge sims' moods tend to tank once they've learned everything simply because they've done everything they could possibly want. There should be more to learn, and more interesting things to do with all the skills they got. Maybe I could also make it so characters aren't going to be rolling lifetime wants that make money if they have a lot. If they have a lot, they're going to want to relax and waste time with all the expensive stuff they have now. They got money, they shouldn't be interested in working. Only fortune sims should want work all the time, and only they should be rolling wants for promotions one after the other. Just because they could still advance they shouldn't normally focus around getting the skills they need to advance another level even if they clearly have no use for the money. If they want money, it should be in an indirect way such as wanting a better telescope or something. If you don't need more money to do it, you shouldn't be seeking more wealth basically.

Less free money. The game is actually quite generous with donations. If you have one of the later expansions installed, an npc will come to your house within the first few hours of gameplay and give you a highly expensive computer. Many challenges actually forbid you from selling this item. Getting promoted also gives you a ludicrous bonus; often several times that of your salary. Its actually the main reason why sims can build wealth so fast. Then there's dating. If your sim has had a successful date with someone, there's a chance they're going to come to your house and gift you an ultra expensive item you can easily sell to get a boost to funds equivalent to a promotion. Clearly, all such things must be removed; if you get a bonus, it should be for doing something clever at work. If you want to save up money, you're just going to have to rely on not spending your salary. If you want to accumulate wealth, you're really going to have to work hard for it; its not going to be handed to you.

Of course, at the end of the day this all may only delay the inevitable. No matter how hard you make it to accumulate funds, sooner or later you should be able to become trillioinaires. If you're making even slightly more money than your taxes are eating up, its still going to gradually accumulate. Items breaking down would probably help the most, since it will always be setting you back to square one. Honestly though, such a thing could be annoying, especially since you're likely to have purchased a bunch of stuff at the same time, meaning that one day seemingly everything in your house is going to fail, and if you have a lot of items and/or they're just expensive you probably won't be able to replace everything, possibly causing major problems for the family out of nowhere. Skills are another issue; how do you determine what skills a pre-made adult should have? In the sims 2, you can easily max all skills before adulthood if you try. Why then is not everyone fully skilled? What would be the typical level of skill for an average adult character? Should I place a cap on how high skills can go before the adult stage (in the sims 2, toddlers can actually max out 3 skills pretty easily, seriously). That seems kinda heavy-handed though to just say 'you can't progress past this point until you're an adult'. Most skills are tied to personality traits; the personality values affect how fast you can level skills. Maybe I could also use them to set a cap? If you're not an adult yet and you only have an outgoing score of say 5, you shouldn't be able to raise your charisma past that until you've come of age. There just doesn't seem to be a good solution though.
The things causing this one problem are numerous. All games seem to suffer from this; once you've got everything in Skyrim or Minecraft, the game becomes boring. You can't possibly die, and you have everything you could ever need to do whatever you want. There's no way for you to fall back down once you're at the top. Maybe this problem is just impossible to solve?

It seems that the answer to this -and some of your previous- questions is quite subjective and will ultimately need actual play testing to answer. What extends the enjoyment of your particular game is going to depend heavily on the exact situation presented to a late-game player. What is that becomes tedious/loses entertainment value when playing late-game? Is it the excess of money? Or boredom with the lack of furniture options? Or ...

Honestly, for me it was mostly seeing my character pass away. After that, it felt like I was just re-playing him with an npc. However, for some reason starting a new playthrough always fixed this. Maybe I just preferred to play characters I had made over 'natural' ones? Maybe I can't know until I playtest, but what if I need to add something but I would need to re-do the whole game to implement it? You can't just keep adding on features to the same game, you're just going to end up with a game filled with contradicting and redundant features.

Every game will become boring eventually. There are only two possible solutions to really solve this and both come down to the same root. The human element.
These two ways are "Multiplayer" (Humans to play with/against) and "Live Service"(humans that perpetually add content).
If it is not a multiplayer (pvp focussed) game and you plan to eventually be done with developing it, there is just nothing you can do. At some point the player will have experienced all content. Additional content and randomization can push that limit further, but never break it.

Games like The Sims 2, I didn't stop playing because I got bored. I stopped playing them because THEY WERE TAKEN AWAY FROM ME. My computer can't run The Sims 2, and the evil empire EA refuses to make it available again. I can't play Skyrim either, despite spending YEARS trying to get it to run on my computer. I quit terraria because the 1.4 update rendered the game unplayable to me. I would still be playing all of these today if I had a choice in the matter. So forever games do exist, they just keep getting torn away from us.

You may be interested in reading Finite_and_Infinite_Games.

So, basically a finite game has a story with an endpoint, and infinite ones are played for the sake of being played. The best example of the latter to me would be arcade games. There's no real end point. You can always make a higher score, you can survive for more levels in pac-man. The sims 2 is a bit of both. Your sims do have an end goal in their 'lifetime wants', and of course they are mortal (though there was ways to remove that, such by making them a vampire).

Their wants are finite in number, but many are infinitely repeatable. They only have access to 4 or 6 at a time, so which ones they want you to make them do is always in flux. Sims can also reproduce, continuing the cycle indefinitely. Of course, you do have a problem where sims born during gameplay rather than pre-made as full grown adults have an advantage in that they have far more time to build up skills and friends and acquire other things, meaning the difficulty drops after the first generation.

I was also thinking that maybe the progression is too fast. There's a lot for you to achieve, but honestly you can easily acquire everything within the span of a pre-made adult becoming an elder. Its not going to take you generastions to build up that mansion. There is quite a gradient of furniture items for you to buy, but its not hard to get to the top rather fast. No matter how many tiers of items you add, eventually you're going to reach the end. My solution to solve this way to change the goal from 'get to the top' to 'stay at the top as long as you can'.

Essentially, this would turn the game into 'get the highest score possible'. How long can you keep that mansion? How far can your family lineage continue? Can you keep your sims happy until its their time to go? In light of that, maybe I shouldn't incorporate the 'lifetime want' feature. The reward for doing it was making your sim eternally happy, meaning they really didn't have to do anything anymore. This was added in an expansion, so in the base game 'perma-plat' wasn't possible. I admit, I was sorta annoyed by all my sims suddenly having a master plan they were working on.

So in summary, remove the lifetime want thing, and other end-game 'achievements'. Make the point of the game being to play it. Add more randomization into it to keep gameplay from becoming repetitive. Make it open-ended. Of course, incorporating things like the legacy and apocalypse challenges would put in an end-goal, though at least with the apocalypse challenge you can always try it again to complete it faster, and with the legacy challenge you could always change out the restrictions you had, or even play both challenges at the same time!

That said, honestly I always prefer to have SOME things stay the same. I like meeting the same npcs in every play-through, its like visiting old friends. I never liked totally random games. All humans prefer some form of stability in their lives. Yeah, they get bored if nothing gets changed up, but they tend to lose interest if there's nothing permanent they can acquire. Nobody likes a Sisyphean task. Thus to enjoy something, it has to be a little of both. There must be both permanence and change, not just one or the other.

Been thinking about this more. Maybe the expansions did a lot of harm to the game honestly. Several expansions kept adding in more stuff that made the game easier. University added perma-plat, seasons added boosts to all socials and faster skill building, freetime added ways to reduce need decay in multiple ways plus another way to achieve perma-plat, and bon voyage added even more social boosts and faster skill building. The game would be better if it didn't have any of these features (though the seasons encouraging certain behaviors is quite interesting).

Essentially, I would only incorporate features that actually add new stuff to the game, such as gardening, crafting, vacationing, pets, life states, etc, but virtually none of the stuff that just made the game easier and easier with every expansion. Certainly reduces a lot of work for me. Though as said I may keep the seasons thing, since it does encourage you to mix up your gameplay, and the lifetime aspiration thing from freetime may be okay too since it would only make permaplat possible near the end of a sim's life, which I'm fine with. May leave it anyway though.

From your thoughts I read that you are trying to make the game that you would want to play. This is completly okay, but has a high risk of not appealing to a wider audience. If this is just some kind of hobby project broader success is not the goal and you can totally continue in that direction. With some luck even then your personal taste can appeal also to many other people.
However if your goal is to appeal to a wider audience I suggest you take a step back and also look into the game design from a more objective perspective.

There are a number of reasons a player may want to play a game.

The story and characters make the player want to see what comes next
The game presents a challenge that the player wants to overcome
There is an area of the world for the player to explore
Etc. There may be others.

Without a reason to play the game, the player will generally not continue to play. Once all challenges presented by the game have been accomplished and there is no story or anything to explore, how could you expect a player to continue playing?
If you want players to continue to play, you must offer them more content to play.
Your suggested solutions #1 and #2 don't offer additional content, rather they require players to re-play existing content. Players will generally not do that unless there's a value-add. Asking players to re-play existing content can be done, with the cons that you must not make it seem like an unfair penalty and you must provide enough variability that players look forward to playing the game again. For example, roguelike games specialize in asking players to replay content, and they succeed because each run is randomized.
For example: Once a player reaches a state where everything in the game is unlocked, declare the player the "Winner of The Sims" somehow, and then give them a few bonuses and unlock a new feature for their next game.
Solutions #3 #4 and #5 don't offer additional content either, they only make progressing through the content more difficult and slower. That may be a valid option for you, with the cons that players do not like excessive grinding.
But no matter how much you add, players will eventually reach the end of your content and stop playing. But, that is a good thing. It's hard enough to get players to play your game at all. If you can somehow convince a significant subset of players to play all the way to the end of your game,
then congratulations! You have won as a game designer and done better than most other games out there.
On that note: The above paragraphs were "answering the question", so forgive me but this last paragraph will be "advice". I don't know anything about your situation but I'm going to guess that you're an indie developer with a small team and a new IP, near the beginning of your project. If that's the case, then you're worried about the wrong thing. It will be hard enough to get players to play the beginning of your game. Focus on delivering your core loop first, and then worry about endgame content once your core loop is good.

I am NOT an indie developer. I don't have a team. Why would I be making a text-based game using just base python/c++, where the only output function avaiable is 'print/cout'. I'm making this for myself, no one else. Besides, there's no way I could release such a thing without EA accusing me of copyright infringement. If I had an actual team, I would be making a game with proper graphics, not text. I'm just desperate to have my games back no matter what it takes. I'm sick of things being taken away from me with no compensation. Fuck EA and any company that destroys their own games.

Regarding 'new content', this being my game I can always add more, which I was planning to do anyway (I did play with certain mods, and besides I always wished it did have certain features that were never added). I don't know how far I can really expand a text-based game, but I kept playing The Sims 2 for YEARS after the expansions stopped, and that wasn't because of mods. Maybe its replayablity was due to the sheer number of ways you could design your house and dress up your sims. There was also a randomization element to it too which probably helped.

Regarding #4, honestly I was thinking it would be a good idea to distinguish the different aspirations more. As-is, its impossible to get overworked. Regardless of who your sim is, you can keep them happy by just having them go to work all the time. No matter how much you overwork your sims, they're never going to lose it. Only fortune sims should want that; everyone else should want things not directly related to work. The family sims should lose if it they aren't having kids and interacting with them. The popularity sims should only gain happiness from making friends.

They can all still work of course, but it should serve another goal; only fortune sims make money just for the sake of making money. Everyone else should only be making money if the practically need it. Thus, the player has to chose between making their sims happy, and making sure they're making enough to live and progress. Family sims should roll wants to quit their job, popularity sims should roll wants to switch to jobs with shorter working hours, even if they pay less. Basically, money only brings happiness if you're a fortune sim. That should help mix up gameplay.


text:
A good genetic system?
I was trying to come up with a genetic system for my game. However, after doing the math I found the system I had in mind won't really work.
Characters have 5 stats that can range from 0 to 12. What I was planning on doing was averaging each stat, and then rolling two numbers for each. The one that would be inherited for each stat would be the one closest to the average.
However, I found the bias isn't that great. For any number between 0 and 12, there's a 23/144 chance, or about a 15% chance of it occurring. This means say that if the two parents had a 12 in a score, there was an 85% chance about that the offspring's score would be lower than 12. Clearly, that isn't going to work. If both parents have the highest number, the odds should be weighed far more towards them.
I could increase the number of rolls, but adding more rolls decreases the odds of the farthest result too much.
If it matters, I'm trying to recreate the genetic system of The Sims 2. I have no idea how it generated its results, other than that all possibilities would possible but somehow weighted based on the parents. The totals of all 5 stats were also always between 25 and 35. I know how that was accomplished, but it doesn't help me with the first part.
I did think of an alternate method, but I don't like it much either. I was thinking of taking the averages of the parents, and then incrementing every stat at random x times, then doing it again x times but this time decrementing. This however doesn't work too well either. Either it would heavily weigh scores towards the middle, or it would make it nigh impossible for a child to match its parent. If I added too many increments/decrements, it would probably result in the final stats bearing no resemblence to the parents. I may as well just be starting with 0, and incrementing stats at random until a total of 30 is reached.
What would be a good system for my game?
update: Thinking about the latter system, I've come to realize its inherently flawed. The problem comes from the fact that the program has to either increment or decrement first. I could have it alternate back and forth, but it may not help much. The issue arises in the fact that no value can be raised above 12. I solved this by having the problem just skip over stats that are 12 when its incrementing, and skipping over values of 0 when its decrementing. This means that if a stat is 0, it has a 0% chance of being incremented, and the other four have a 25% chance of being incremented. When it switches to decrementing, all have a 20% chance of being decremented (assuming none of them are zero of course). Thus the 12 stat is more likely to be decremented than incremented, while the remaining stats are more likely to incremented instead. Stats of 0 would suffer the same problem, but in reverse. This means that this system actually evens out the numbers, and makes it nigh impossible to have a stat of 12 or 0. In order for that to happen, the program would have to in its six tries not chose these stats all six times. That's less than 1/5000 chance about. So clearly this system sucks. Thus I need to pick something more neutral.
There does need to be a randomization element to it. If I just had all the offspring's stats be the average of its parents, then all siblings would have the exact same stats. There has to be some way for them to vary.

My approach would be to take three numbers per stat, mother, father and a random roll between 0 and 12, and then take the average. That will mean that the score will usually be somewhere between mother and father. But for exceptionally good or bad parents, there will be some regression to the mean, and for cases where both parents are very similar, there is a good chance that the child will be slightly better or worse than them. Extremely good or extremely bad values would be quite rare in this system, but possible.
This system could be refined further by changing the respective weights of the parents genes and the random factor.
However, this system doesn't have any guarantees about the sum of the stats. In order to then get a total sum between 25 and 35, I would then "normalize" the stats. I would do that by:

calculating their sum
divide that sum by the desired sum of 30 to get the factor of how much that sum is above or below the desired sum.
apply that factor by dividing each individual stat by it
round the results to the nearest integer.

Example:
A: 5
B: 7
C: 10
D: 5
E: 9

Sum: 36

This character is 36 / 30 = 1.2 times as good as they should be. So we divide all stats by 1.2 and then round them:
A: 5   / 1.2  = 4.166 ~= 4
B: 7   / 1.2  = 5.833 ~= 6
C: 10  / 1.2  = 8.333 ~= 8
D: 5   / 1.2  = 4.166 ~= 4
E: 9   / 1.2  = 7.5   ~= 8

Sum: 30

Note that if you have 5 values that sum up to 30, and you round each one up or down to the nearest integer, then you always end up somewhere between 25 and 35.

That's actually an interesting suggestion. Though I don't see how it would be possible to have all values come up. If the parents scores were both 0, and the roll was a 12, the average would be a 4. Thus, there would be no way to get a 12, or anything above 4. Even if both parents had a 6 (or their scores averaged out to 6), the highest the offspring could get is 8. So that's a range of 4 to 8, not 0 to 12. I was thinking that honestly maybe its just futile, and I need to accept that the offspring will never be that far off from the average of their parents.

The last method I mentioned in the post btw generates similar results. Assuming the average of the parents is 6, the highest the offspring seems to get is a 10, on freak occasions an 11, though both are clearly the exception rather than the norm (only about 1/10 of the values I generate seem to ever contain a 10 or 11, have yet to see one get a 12). Amusingly though, I rarely get a 12 even if the starting average is 12. Probably because there's 6 chances of it getting decremented, and also the decrements all happen after the increments. Perhaps I should fix that somehow.

If you want more chance of outliers, you could adapt the above system to have two rolls - one roll for the 0-12 as taken above, and some other (real number) distribution from 0-1 to indicate what weight that roll has, so 0 would mean a straight average of the parents, 1/3 would weight all three rolls equally, 1 is using only the 0-12 roll. Tweak the 0-1 distribution to get the outcomes you want.

That's actually kinda how the system works in the sims 2 apparently. Strangely, it apparently never takes both parents into account. It only factors in one, or sometimes neither, in which case the values the offspring get are completely up to rng. Come to think of it, maybe that's how all possible results can come up, despite often being biased towards the parent's values. 2/3 times it bases the numbers on one of the parents, the rest not. Its not perfect though; it suffers a glitch that causes most children to have 0 nice points. Seriously.

You could consider taking some inspiration from biology, emulating genes by making the visible stat just the "phenotype" expressed by an underlying "genotype" in the data used under the hood.
So for instance, instead of storing a stat as one number 0-12, maybe it's four separate "genes" each holding a value 0-3 (convenient to store in a "nibble" of 4 bits — half a byte), and the visible stat is the sum of these four genes.
So a sim with a 12 stat definitely has all 3 genes, but a sim with a 6 could have genotypes 0 0 3 3 or 1 1 2 2 or 0 1 2 3 etc.
When creating offspring, emulate crossover and dominance interactions between genes by randomly selecting two genes from each parent to make the four genetic components of the child's stat. Then you can add mutation by having a small chance that each gene mutates to a random value.
You can preferentially mutate-to-decrease when at the high end of the 25-35 total band, and mutate-to-increase at the low end, but without preferentially targeting 0s or 3s specifically. So an individual who's been tweaked to fit the target range can still have some extreme genes in the mix; they don't all gravitate to the average.
(Before any bio geeks storm the comments: yes, this is not how mitosis/mutation/etc. actually works. If you wanted, you could have each parent contain two copies of every gene, then pass on one of those two copies to the child, then have some rule for which copy/copies affect the stat... but I think that's more complex than you need to go for this feature, and the simplified approximation "loosely inspired" by biology gives fewer surprising results where a child gets all the parents' recessive genes and has drastically different stats, looking like a glitch)
With this approach, parents with high stats due to having a lot of 3s will tend to have children with a lot of 3s and similarly high stats, but not always, and likewise for low stats. The chance mutation still gives some chance of children having very different stats — any value could arise by mutation, but values not too different from the parents' are more likely — and you can control how often this happens by tuning the mutation rate.

Yeah, I was thinking of emulating real-world genetics into the game. The sims 2 does this for physical appearance, it even goes so far as to do the dominant/recessive gene thing, and have genes not express themselves, allowing traits to skip generations (assuming the whole thing doesn't bug out and just start making ever sim born in-game a clone). I thought however that such complexities were unnecessary. I could make this game literally like dwarf fortress and try to emulate reality to the tiniest detail, but that would be a lot of work and I don't really see it adding much.

If I was to emulate the real world, I would be giving my sims an actual appearance (I may do that anyway though, since apparently one of the handicaps for the sims 2 legacy challenge requires all spouses to have a different hair and skin color). I would also emulate actual nutrition, which would justify having multiple meals like the real game does. I would even have the game actually have a map and have characters moving around in it. However, I never saw such minutia really offering anything in dwarf fortress, so why would I bother with stuff like this in my game?

On that note, if I was going to go the dwarf fortress route, then why not just play dwarf fortress? Honestly, I never really cared for that game. What's the fun in building this epic base only to see it get leveled over and over again by things that are stupid OP? Of course, part of my dislike of the game is the AI. Yeah, I know not much can be done about that, but you could AT LEAST MAKE IT POSSIBLE TO TELL YOUR DWARVES TO STUFF THEIR STUPID FACES INSTEAD OF STARVING TO DEATH WITH A MOUNTAIN OF FOOD SITTING IN STORAGE.

You may want to edit your question to include more specific criteria about what traits a "good" system should have and what level of complexity is too much, to help focus potential answers on the types of solutions you're looking for, so users don't have to guess at your requirements.

Yeah, I was thinking that. But what would constitute a 'good' system? I sorta already explained it; a system that creates clear bias towards the stats of the parents, while leaving all possibilities possible. Essentially, if both parents have a 12 in a stat, there should be a bias towards 12 for all offspring, but even a 0 shouldn't be impossible. Of course, even if all results are possible, having a .001% chance of a 0 occurring would probably still make it rare. There just seems to be no way to make 12 the most likely without making 0 impossible.

As I explained, I found out the way The Sims 2 accomplishes this is to just not take either parent's numbers into account 1/3 times. Guess if I want this system, I'll just have to emulate that even if it makes no sense at all.

You now have two answers (counting MadMan's comment augmenting Philipp's answer) that show ways for two 12-score parents to tend to produce 12-score offspring most often, while having a possibility of any value including zero (where you can control how likely that is). So both these approaches described so far can meet the criteria you've described in the question. If you're unsatisfied with them, then there are probably additional criteria that are still implicit, and would benefit from being made explicit in your question.

To "see the parents" in their young ones you could implement following system:
each stat has a 33.3% chance to be inherited from the father, 33.3% chance to be inherited from the mother and 33.4% chance to be a random values between 0 and 12.
If the value is inherited from a parent you could make it a range of +-1 around that to not have the exact values of the parent.
At the end you can randomly increase/decrease values until you hit your desired total, but I would suggest to have a much greater chance to change the not-inherited values in this step as to not destroy the feeling of inheritance.
To make it even safer you could make a rule that always at least one stat is inherited from each parent, so you always have at least one stat where you can say: "I inherited that from my father/mother"

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
com.android.build.gradle.internal.tasks.compressassetsworkaction
When I build with asset size of above 5gb, it shows "com.android.build.gradle.internal.tasks.compressassetsworkaction" in unity. How to resolve it?. It's a video file. When I use low resolution file, it works fine. Is that any way to build an apk without compressing video file?

Aren't Android asset packs limited to 4GB max? If your video doesn't compress to less than that, you may need to chop it into smaller pieces and play the pieces back-to-back.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Raycaster rotation problem
I am following lodevs tutorial on Raycasting https://lodev.org/cgtutor/raycasting.html.
I was kinda successfull but for some reason while implementing a 2D Topdown view of the map and the player i have a rotation problem.
When rotating left in the raycaster view i rotate left. But in the topdown view i rotate to the right. I still am looking in the correct direction where i am supposed to be looking but this irritates me and i dont know why this is.
Here is a link to visualize what i mean: https://youtu.be/c26RObAi2Os.

#include "main.h"
#include "SDL2/SDL_render.h"

int pixels[SCREEN_HEIGHT][SCREEN_WIDTH];
uint textures[8][TEX_WIDTH * TEX_HEIGHT];

int worldMap[MAP_HEIGHT][MAP_WIDTH] = {
    {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7, 7, 7, 7},
    {4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 7},
    {4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7},
    {4, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7},
    {4, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 7},
    {4, 0, 4, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 0, 7, 7, 7, 7, 7},
    {4, 0, 5, 0, 0, 0, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 7, 0, 0, 0, 7, 7, 7, 1},
    {4, 0, 6, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 7, 0, 0, 0, 0, 0, 0, 8},
    {4, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 1},
    {4, 0, 8, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 7, 0, 0, 0, 0, 0, 0, 8},
    {4, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 7, 0, 0, 0, 7, 7, 7, 1},
    {4, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 1},
    {6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
    {8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
    {6, 6, 6, 6, 6, 6, 0, 6, 6, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
    {4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 6, 0, 6, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3},
    {4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 0, 6, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2},
    {4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 2, 0, 0, 5, 0, 0, 2, 0, 0, 0, 2},
    {4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 0, 6, 2, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2},
    {4, 0, 6, 0, 6, 0, 0, 0, 0, 4, 6, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 2},
    {4, 0, 0, 5, 0, 0, 0, 0, 0, 4, 6, 0, 6, 2, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2},
    {4, 0, 6, 0, 6, 0, 0, 0, 0, 4, 6, 0, 6, 2, 0, 0, 5, 0, 0, 2, 0, 0, 0, 2},
    {4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 0, 6, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2},
    {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3}};

static Player player = {.pos = {.x = 11.5, .y = 11.5},
                        .dir = {.x = -1, .y = 0},
                        .plane = {.x = 0, .y = 0.66}};

SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture *buffer = NULL;
void initSDL() {
  // Initialize SDL
  if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
    exit(1);
  }

  window =
      SDL_CreateWindow("Wulf", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                       SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
  if (window == NULL) {
    printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
    exit(1);
  }

  renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
  buffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
                             SDL_TEXTUREACCESS_STREAMING, SCREEN_WIDTH,
                             SCREEN_HEIGHT);
}

void destroySDL() {
  SDL_DestroyWindow(window);
  SDL_Quit();
}

void render() {
  int w = SCREEN_WIDTH / 2;
  int h = SCREEN_HEIGHT;

  for (int x = 0; x < w; x++) {
    // das berechnet welchem x punkt der pixel x auf der
    // kameraebene entspricht links von der richtung in der
    // die der spieler schaut ist der Wert negativ rechts
    // davon ist er positiv und in der mitte ist er NULL es
    // wird also die kameraebene auf den bildschirm gemappt
    double cameraX = 2 * (x / (double)w) - 1;
    double rayDirX = player.dir.x + player.plane.x * cameraX;
    double rayDirY = player.dir.y + player.plane.y * cameraX;

    int mapX = (int)player.pos.x;
    int mapY = (int)player.pos.y;

    double sideDistX;
    double sideDistY;

    double deltaDistX = (rayDirX == 0) ? 1e30 : fabs(1.0f / rayDirX);
    double deltaDistY = (rayDirY == 0) ? 1e30 : fabs(1.0f / rayDirY);
    double perpWallDist;

    int stepX;
    int stepY;

    int hit = 0;
    int side;

    if (rayDirX < 0) {
      stepX = -1;
      sideDistX = (player.pos.x - mapX) * deltaDistX;
    } else {
      stepX = 1;
      sideDistX = (mapX + 1.0 - player.pos.x) * deltaDistX;
    }
    if (rayDirY < 0) {
      stepY = -1;
      sideDistY = (player.pos.y - mapY) * deltaDistY;
    } else {
      stepY = 1;
      sideDistY = (mapY + 1.0 - player.pos.y) * deltaDistY;
    }

    // perform DDA
    while (hit == 0) {
      // jump to next map square, either in x-direction, or in y-direction
      if (sideDistX < sideDistY) {
        sideDistX += deltaDistX;
        mapX += stepX;
        side = 0;
      } else {
        sideDistY += deltaDistY;
        mapY += stepY;
        side = 1;
      }
      // Check if ray has hit a wall
      if (worldMap[mapY][mapX] > 0)
        hit = 1;
    }
    // Calculate distance projected on camera direction (Euclidean distance
    // would give fisheye effect!)
    perpWallDist =
        side == 0 ? (sideDistX - deltaDistX) : (sideDistY - deltaDistY);

    // Calculate height of line to draw on screen
    int lineHeight = (int)(h / perpWallDist);

    // calculate lowest and highest pixel to fill in current stripe
    int drawStart = -lineHeight / 2 + h / 2;
    if (drawStart < 0)
      drawStart = 0;
    int drawEnd = lineHeight / 2 + h / 2;
    if (drawEnd >= h)
      drawEnd = h - 1;
    // texturing calculations
    int texNum = worldMap[mapY][mapX] - 1;

    // calculate value of wallX
    // where exactly the wall was hit betwen 0 and 1 => uniform grid world
    double wallX = side == 0 ? player.pos.y + perpWallDist * rayDirY
                             : player.pos.x + perpWallDist * rayDirX;
    wallX -= floor((wallX));

    // x coordinate on the texture
    int texX = (int)(wallX * (double)TEX_WIDTH);
    if (side == 0 && rayDirX > 0)
      texX = TEX_WIDTH - texX - 1;
    if (side == 1 && rayDirY < 0)
      texX = TEX_WIDTH - texX - 1;

    // SDL_Log("y0:%i y1:%i: color:%i",drawStart,drawEnd ,color);
    double step = 1.0 * TEX_HEIGHT / lineHeight;
    // Starting texture coordinate
    double texPos = (drawStart - (float)h / 2 + (float)lineHeight / 2) * step;
    for (int y = drawStart; y < drawEnd; y++) {
      // Cast the texture coordinate to integer, and mask with (TEX_HEIGHT - 1)
      // in case of overflow
      int texY = (int)texPos & (TEX_HEIGHT - 1);
      texPos += step;
      Uint32 color = textures[texNum][TEX_HEIGHT * texY + texX];
      // make color darker for y-sides: R, G and B byte each divided through two
      // with a "shift" and an "and"
      if (side == 1)
        color = (color >> 1) & 8355711;
      pixels[y][x] = color;
    }
  }
}

void render2D() {
  int offset = SCREEN_WIDTH / 2;
  for (int y = 0; y < MAP_HEIGHT; y++) {
    for (int x = 0; x < MAP_WIDTH; x++) {
      if (worldMap[y][x] != 0) {
        int offsetY = y * TILE_HEIGHT;
        int offsetX = offset + x * (TILE_WIDTH);
        for (int ty = 0; ty < TILE_HEIGHT - 1; ty++) {
          for (int tx = 0; tx < (TILE_WIDTH - 1); tx++) {
            pixels[offsetY + ty][offsetX + tx] = 0x5088ff;
          }
        }
      }
    }
  }
}

void drawPlayer2D() {
  int py = player.pos.y * TILE_HEIGHT;
  int px = player.pos.x * (int)TILE_WIDTH + SCREEN_WIDTH / 2.0;
  int dx = player.dir.x * 3 + px;
  int dy = player.dir.y * 3 + py;
  SDL_Rect r = {.x = px - 5, .y = py - 5, .w = 10, .h = 10};
  SDL_Rect d = {.x = dx - 3, .y = dy - 3, .w = 6, .h = 6};

  SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
  SDL_RenderFillRect(renderer, &r);
  SDL_SetRenderDrawColor(renderer, 255, 125, 255, 255);
  SDL_RenderFillRect(renderer, &d);
}

void rotate(float rot) {
  const v2 d = player.dir, p = player.plane;
  player.dir.x = d.x * cos(rot) - d.y * sin(rot);
  player.dir.y = d.x * sin(rot) + d.y * cos(rot);
  player.plane.x = p.x * cos(rot) - p.y * sin(rot);
  player.plane.y = p.x * sin(rot) + p.y * cos(rot);
}

void generateTextures() {
  memset(textures, 0, sizeof(textures));
  for (int y = 0; y < TEX_HEIGHT; y++) {
    for (int x = 0; x < TEX_WIDTH; x++) {
      int xorcolor = (x * 256 / TEX_WIDTH) ^ (y * 256 / TEX_HEIGHT);
      // int xcolor = x * 256 / TEX_WIDTH;
      int ycolor = y * 256 / TEX_HEIGHT;
      int xycolor = y * 128 / TEX_HEIGHT + x * 128 / TEX_WIDTH;
      textures[0][TEX_WIDTH * y + x] =
          65536 * 254 *
          (x != y && x != TEX_WIDTH - y); // flat red texture with black cross
      textures[1][TEX_WIDTH * y + x] =
          xycolor + 256 * xycolor + 65536 * xycolor; // sloped greyscale
      textures[2][TEX_WIDTH * y + x] =
          256 * xycolor + 65536 * xycolor; // sloped yellow gradient
      textures[3][TEX_WIDTH * y + x] =
          xorcolor + 256 * xorcolor + 65536 * xorcolor; // xor greyscale
      textures[4][TEX_WIDTH * y + x] = 256 * xorcolor;  // xor green
      textures[5][TEX_WIDTH * y + x] =
          65536 * 192 * (x % 16 && y % 16);            // red bricks
      textures[6][TEX_WIDTH * y + x] = 65536 * ycolor; // red gradient
      textures[7][TEX_WIDTH * y + x] =
          128 + 256 * 128 + 65536 * 128; // flat grey texture
    }
  }
}

void playerBoundsCheck() {
  if (player.pos.x >= MAP_WIDTH) {
    player.pos.x = MAP_WIDTH - 10;
  } else if (player.pos.x < 0) {
    player.pos.x = 10;
  }
  if (player.pos.y >= MAP_HEIGHT) {
    player.pos.y = MAP_HEIGHT - 10;
  } else if (player.pos.y < 0) {
    player.pos.y = 10;
  }
}

int main() {
  initSDL();
  generateTextures();
  int pitch = SCREEN_WIDTH * sizeof(int);
  void *rawPixels = NULL;

  SDL_Event e;
  double time = 0;
  double oldTime = 0;
  bool quit = false;
  while (!quit) {
    while (SDL_PollEvent(&e)) {
      if (e.type == SDL_QUIT)
        quit = true;
    }

    oldTime = time;
    time = SDL_GetTicks();
    double frameTime = (time - oldTime) / 1000.0;
    const float rotspeed = 5.0f * frameTime, movespeed = 5.0f * frameTime;

    const uint8_t *keystate = SDL_GetKeyboardState(NULL);
    if (keystate[SDL_SCANCODE_LEFT]) {
      rotate(-rotspeed);
    }

    if (keystate[SDL_SCANCODE_RIGHT]) {
      rotate(+rotspeed);
    }

    if (keystate[SDL_SCANCODE_UP]) {
      player.pos.x += player.dir.x * movespeed;
      player.pos.y += player.dir.y * movespeed;
      playerBoundsCheck();
    }

    if (keystate[SDL_SCANCODE_DOWN]) {
      player.pos.x -= player.dir.x * movespeed;
      player.pos.y -= player.dir.y * movespeed;
      playerBoundsCheck();
    }

    SDL_RenderClear(renderer);
    SDL_LockTexture(buffer, NULL, &rawPixels, &pitch);

    memset(pixels, 0, sizeof(pixels));
    render();
    render2D();

    memcpy(rawPixels, pixels, pitch * SCREEN_HEIGHT);
    SDL_UnlockTexture(buffer);
    rawPixels = NULL;
    SDL_RenderCopy(renderer, buffer, NULL, NULL);
    drawPlayer2D();

    SDL_RenderPresent(renderer);
  }

  return 0;
}


text:
How to move the bones of a model by just pressing a key in unreal engine 5?
I have the following problem. I need to be able to rotate a bone (any bone) in a model in unreal engine 5.3. I cannot use the timeline. For example, if I press the space bar then I would need the arm to rotate. I cannot find a way to do it. Any recommendations?


text:
Pygame showing surfaces at wrong coordinates with full screen
So I coded this line for the display surface:
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN|pygame.NOFRAME)
But the thing is, when I place a rectangle at coordinates like (0,0), they are not shown on top left corner, but actually at about the middle of the screen.
Here's my full code:
import pygame

pygame.init()

screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN|pygame.NOFRAME)
clock = pygame.time.Clock()

rect = pygame.image.load('graphics/rect.png')

while True:

    screen.fill("Black")
    screen.blit(rect, (0,0))
    pygame.display.update()
    clock.tick(60)
```

I tested your code and the rectangle image I have shows at the top-left of the screen. What image do you use, and what is the final result you have?


text:
How do I morph a player's character to a specified player's character?
I'm making a shapeshift command that you can run via chat. It works pretty similar to how HD Admin handles character morphin (https://create.roblox.com/marketplace/asset/13549366436)
I know how to get the model a specified player's avatar by using HumanoidDescription. However, I want to make a new rig with the specified avatar. The reason I want to do this is so that I can put a" animation during the command. How do I do this?
Code (Simplified)
{
            PrimaryAlias = "shapeshift",
            SecondaryAlias = "change",
            PermissionLevel = 0,
            Function = function(player: Player, args: { string })
                local TemporaryRig = game.ReplicatedStorage.Rig.R15:Clone()
                TemporaryRig.Parent = game.Workspace

                game.Players.PlayerAdded:Connect(function(player)
                    TemporaryRig.Position = player.Character.Position -- Main Problem
                        local id = PlayerService:GetUserIdFromNameAsync(args[1])
                        print(id .. " returned when GetUserIdFromNameSync") -- Debug
                        print(args[1] .. " returned") -- Debug
                    local newHumanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(id)
                    TemporaryRig.Humanoid:ApplyDescription(newHumanoidDescription)
                end)
                end,
        },
```


text:
Unreal Engine: How to edit the M_Athena_Terrain_IceBiome.M_Athena_Terrain_IceBiome material?
I'm using the snow landscape as described here:
https://www.reddit.com/r/FortniteCreative/comments/12100h0/terrain_materials_uefn/
This is the full path to the material:
/Script/Engine.Material'/Game/Athena/Environments/Landscape/Creative/M_Athena_Terrain_IceBiome.M_Athena_Terrain_IceBiome'
However, I cannot find anywhere this M_Athena_Terrain_IceBiome.M_Athena_Terrain_IceBiom in content browser or file explorer. Double clicking on that material doesn't open anything. So, it seems that I cannot edit that material, and I can't even find/locate it.
If I can create a new material that's based on that Athena icebiome, that'd work too, but it seems like I can only create materials from scratch.
The reason I'm trying to edit this material is that I need to connect a landscape visibility mask to its Opacity Mask so I can use the Visibility tool to create a hole inside that snowy mountain/terrain.
I'm using Unreal Engine for Fortnite (UEFN), but I think it's pretty close to the full UE5.


text:
Need help with artefacts when rendering shadows using a shadow map
I am encountering some weird artefacts when rendering shadows using a shadow map.
I am using C++ with Vulkan and GLSL shaders.

This is the vertex shader that calculates the light_space_position:
#version 450

layout(location = 0) in vec3 in_position;
layout(location = 1) in vec3 in_normal;
layout(location = 2) in vec2 in_uv;

layout(location = 0) out vec3 out_position;
layout(location = 1) out vec3 out_normal;
layout(location = 2) out vec2 out_uv;
layout(location = 3) out vec4 out_light_space_position;

layout(binding = 0) uniform uniform_scene {
  mat4 view;
  mat4 projection;
  vec3 camera_position;
  mat4 light_space;
} scene;

void main() {
  out_position = vec3(object.model * vec4(in_position, 1.0));
  out_normal = normalize(mat3(object.normal) * in_normal);
  out_uv = in_uv;
  out_light_space_position = scene.light_space * vec4(out_position, 1.0);

  gl_Position = scene.projection * scene.view * vec4(out_position, 1.0);
}

This is the fragment shader code:
layout(location = 0) in vec3 in_position;
layout(location = 1) in vec3 in_normal;
layout(location = 2) in vec2 in_uv;
layout(location = 3) in vec4 in_light_space_position;

layout(location = 0) out vec4 out_color;

layout(binding = 0) uniform uniform_scene {
  mat4 view;
  mat4 projection;
  vec3 camera_position;
  mat4 light_space;
} scene;

layout(binding = 2) uniform sampler2D image;
layout(binding = 3) uniform sampler2D shadow_map;

const vec3 light_position = vec3(2.0, 5.0, 2.0);

float calculate_shadow(vec4 light_space_position, vec3 light_dir) {
  vec3 projection_coords = light_space_position.xyz / light_space_position.w;

  projection_coords = projection_coords * 0.5 + 0.5;

  float current_depth = projection_coords.z;

  float closest_depth = texture(shadow_map, projection_coords.xy).r;

  float bias = max(0.05 * (1.0 - dot(in_normal, light_dir)), 0.005);

  return (current_depth - bias) > closest_depth ? 1.0 : 0.0;
}

void main() {
  vec4 color = texture(image, in_uv);

  vec4 light_color = vec4(1.0, 1.0, 1.0, 1.0);
  // ambient
  vec4 ambient = 0.15 * light_color;
  // diffuse
  vec3 light_dir = normalize(light_position - in_position);
  float diff = max(dot(light_dir, in_normal), 0.0);
  vec4 diffuse = diff * light_color;
  // specular
  vec3 view_dir = normalize(scene.camera_position - in_position);
  float spec = 0.0;
  vec3 halfway_dir = normalize(light_dir + view_dir);
  spec = pow(max(dot(in_normal, halfway_dir), 0.0), 64.0);
  vec4 specular = spec * light_color;
  // calculate shadow
  float shadow = calculate_shadow(in_light_space_position, light_dir);

  out_color = (ambient + (1.0 - shadow) * (diffuse + specular)) * color;
}


text:
How to trigger a local file download for a screenshot from a Unity WebGL game?
Is it possible for a Unity WebGL app to trigger a local file download - binary data generated in the app, somehow triggering a browser download?


text:
Why when switching between scenes the loading transitions is loading empty scene before loading the scene in index 1?
I have two scenes:  Opening Scene and Game Scene.
The logic is to play the Opening Scene and then fade out then when the Game Scene has loaded to fade in when the Game Scene is already loaded.
the problem is that after doing the fadeout it's showing empty scene it's like doing fade in or changing the alpha color of the canvas group and showing empty scene then after a second or two loading the second scene.
but the fade out/in should be making the smooth transition between the scenes.
the canvasgroupfader script is attached to the canvas in the Opening Scene and the VideoManager script is attached to empty gameobject also in the Opening Scene.
this is the canvas group fade script:
using UnityEngine;

public class CanvasGroupFader : MonoBehaviour
{
    public float fadeDuration = 1.0f; // Duration of the fade in seconds
    private CanvasGroup canvasGroup;

    private float targetAlpha;
    private float startAlpha;
    private float startTime;

    private bool isFading;

    private void Start()
    {
        canvasGroup = GetComponent<CanvasGroup>();
    }

    private void Update()
    {
        if (isFading)
        {
            float elapsedTime = Time.time - startTime;
            float t = Mathf.Clamp01(elapsedTime / fadeDuration);

            float newAlpha = Mathf.Lerp(startAlpha, targetAlpha, t);
            canvasGroup.alpha = newAlpha;

            if (t >= 1.0f)
            {
                isFading = false;
            }
        }
    }

    public void StartFade(float startAlphaValue, float targetAlphaValue)
    {
        if (!isFading)
        {
            startAlpha = startAlphaValue;
            targetAlpha = targetAlphaValue;
            startTime = Time.time;

            isFading = true;
        }
    }

    // Public methods to initiate fading
    public void FadeIn()
    {
        StartFade(0f, 1f);
    }

    public void FadeOut()
    {
        StartFade(1f, 0f);
    }
}

and this is how I'm using it:
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Video;
using UnityEngine.UI;
using TMPro;
using System.Collections;
using UnityEngine.SceneManagement;

public class VideoManager : MonoBehaviour, IDragHandler, IPointerDownHandler
{
    public VideoPlayer player;
    public Image progress;
    public TextMeshProUGUI videoFileName;
    public float scrollSpeed = 50f;
    public CanvasGroupFader canvasGroupFader;

    private bool isVideoFinished = false;

    private void Start()
    {
        player.prepareCompleted += Player_prepareCompleted;
        player.loopPointReached += Player_loopPointReached;
        videoFileName.text = player.clip.name;
    }

    private void Player_prepareCompleted(VideoPlayer source)
    {
        isVideoFinished = false;
    }

    private void Player_loopPointReached(VideoPlayer source)
    {
        VideoFinished(source);
    }

    void Update()
    {
        if (player.frameCount > 0 && isVideoFinished == false)
        {
            progress.fillAmount = (float)player.frame / (float)player.frameCount;
        }

        if (!isVideoFinished && player.isPlaying && (ulong)player.frame >= player.frameCount - 1)
        {
            VideoFinished(player);
        }
    }

    public void OnDrag(PointerEventData eventData)
    {
        TrySkip(eventData);
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        TrySkip(eventData);
    }

    private void SkipToPercent(float pct)
    {
        var frame = player.frameCount * pct;
        player.frame = (long)frame;
    }

    private void TrySkip(PointerEventData eventData)
    {
        Vector2 localPoint;
        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(
            progress.rectTransform, eventData.position, null, out localPoint))
        {
            float pct = Mathf.InverseLerp(progress.rectTransform.rect.xMin, progress.rectTransform.rect.xMax, localPoint.x);
            SkipToPercent(pct);
        }
    }

    public void VideoPlayerPause()
    {
        if (player != null)
            player.Pause();
    }

    public void VideoPlayerPlay()
    {
        if (player != null)
            player.Play();
    }

    private void VideoFinished(VideoPlayer source)
    {
        isVideoFinished = true;
        progress.fillAmount = 1f;

        canvasGroupFader.FadeOut(); // Start fade-out effect
        StartCoroutine(LoadSceneAfterFade()); // Start loading the new scene after the fade-out
    }

    private IEnumerator LoadSceneAfterFade()
    {
        // Wait for the fade-out effect to complete
        yield return new WaitForSeconds(canvasGroupFader.fadeDuration);

        // Load the new scene asynchronously
        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(1, LoadSceneMode.Single);

        // Wait until the new scene is fully loaded
        while (!asyncLoad.isDone)
        {
            yield return null;
        }

        // Start the fade-in effect after the new scene is loaded
        canvasGroupFader.FadeIn();
    }

    private void OnDestroy()
    {
        player.prepareCompleted -= Player_prepareCompleted;
        player.loopPointReached -= Player_loopPointReached;
    }
}


text:
In LibGdx, how to add another music format?
I would like to add multiple music formats to the LibGdx library, like .vgm, .mod, .s3m, .xm and so on. I already have the Java code to do so, but it's hard to integrate it with LibGdx code.
I know there is a backend class named OpenALLwjgl3Audio that has the following code:
    registerSound("ogg", Ogg.Sound.class);
    registerMusic("ogg", Ogg.Music.class);
    registerSound("wav", Wav.Sound.class);
    registerMusic("wav", Wav.Music.class);
    registerSound("mp3", Mp3.Sound.class);
    registerMusic("mp3", Mp3.Music.class);

So it would be nice to call this registerMusic("vgm", Vgm.Music.class) from outside this class.

Unfortunately, as it is a backend class, I can't access it from 'core' project:
 ((OpenALLwjgl3Audio) Gdx.audio).registerMusic("vgm", Vgm.Music.class);
 => Error: OpenALLwjgl3Audio can't be resolved to a type

I tried to access the audio variable in the 'desktop' project (DesktopLauncher.java), but it is null until the application is instantiated, and then it enter in a loop:
 ((OpenALLwjgl3Audio) Gdx.audio).registerMusic("vgm", Vgm.Music.class);
 => Nullpointer Exception, as audio is null until the code below executes:
 ...
 new Lwjgl3Application(new Game(), config);

Creating the class Vgm.Music.class in the LibGdx library itself, along with Mp3.class, Ogg.class and so on and edit the OpenALLwjgl3Audio directly. BUT: I would need to use a particular fork of the LibGdx code, as it probably wouldn't enter in the main develop branch, making it harder to keep my project updated.

Any guidelines to achieve this goal?


text:
Unreal Engine FDirectoryWatcherModule catching multiple events per file operation
I followed this post to implement a delegate on a directory that notifies me when a change has happened (add file, delete file or remove file).
This works fine, though the issue is that for each operation, multiple events are triggered. In the Data array containing information from the operation, I see the following behaviour:

When adding an image, Data size is 5 and contains one FCA_Added and 4 FCA_Modified.
When deleting an image, Data size is 1 and contains a FCA_Removed.
When adding multiple images (for example 2 images), Data size is 10 and contains one FCA_Added and 4 FCA_Modified for the first image and one FCA_Added and 4 FCA_Modified for the second image.

Note: Sometimes adding an image will result in fewer FCA_Modified. For example, in another PC, each image results in one FCA_Added and two (rather than four) FCA_Modified.
In any case, the issue remains that Data is providing a large number of events for each operation. If I want to control this with a switch for example, it means each image will trigger my UpdateDynamicMaterialArray multiple times when only one call is required per file.
I attached an image with the console output for a 2 file addition operation. enter image description here

To clarify the console output image, Element action 1 is a FCA_Added and an Element action 2 is an FCA_Modified.
The function I use to control the events:
/**
 * Will trigger when a change (addition, replacement, deletion) is performed on ResourcesDirPath
 * @param Data Array of type FFileChangeData indicating the nature of the change observed
 */
void AMyController::OnProjectDirectoryChanged(const TArray<FFileChangeData>& Data) {
    UE_LOG(LogTemp, Warning, TEXT("Data num: %d"), Data.Num());
    for (FFileChangeData Element : Data) {
        UE_LOG(LogTemp, Warning, TEXT("Element filename: %s"), *Element.Filename);
        UE_LOG(LogTemp, Warning, TEXT("Element action: %d"), Element.Action);
        switch (Element.Action) {
            case FFileChangeData::FCA_Added:
                UpdateDynamicMaterialArray(&Element.Filename, FFileChangeData::FCA_Added);
                //MyReferenceManager->MyHUD->AddTile();
                break;
            case FFileChangeData::FCA_Modified:
                UpdateDynamicMaterialArray(&Element.Filename, FFileChangeData::FCA_Modified);
                //MyReferenceManager->MyHUD->RefreshTile();
                break;
            case FFileChangeData::FCA_Removed:
                UpdateDynamicMaterialArray(&Element.Filename, FFileChangeData::FCA_Removed);
                //MyReferenceManager->MyHUD->RemoveTile();
                break;
            default: ;
        }
    }
}

FFileChangeData docs and EFileChangeAction did not help.
Why does one operation result in multiple events of different type? I suspect this is OS related (I use Windows) and that there is not much I can do. Is this true?
PD: This post was originally created in stackoverflow and moved it here as I was not aware of the existance of this forum.


text:
Clarification on scene graph implementation. Adding object/node to a root node or container?
I learned about scene graphs from this chapter on learnopengl and using this I'm trying to make a simple imgui window that can display the scene graph, but one thing that wasn't made clear/I'm having trouble understanding is would I want a container that holds all the entities/nodes or would I want to create a root node and eevrything gets added to that?
This is some of the code in the chapter I assume this is would be my "node"
class  Entity {
public:
    // Scene graph
    std::list<std::unique_ptr<Entity>> children;
    Entity* parent = nullptr;

    template<typename... TArgs>
    void AddChild(TArgs&... args) {
        children.emplace_back(std::make_unique<Entity>(args...));
        children.back()->parent = this;
    }
}

And this is how I'm using it
    Entity scenegraph; // root node
    scenegraph.name = "Root";

    scenegraph.AddChild(std::move(someEntity));

But I'm not sure if it would be more typical to do something like this instead std::vector<Entity> scenegraph

"More typical" is usually not the real goal we're working toward, just a proxy for something like "easier to work with / scale to real games" or "better performing". Both the approaches you show can work. Do you prefer working in one style or the other, or have you run any tests indicating an unwanted performance bottleneck in one approach or another?


text:
Manual calc of perspective projection and getting point on the screen
I'm need to draw the red rect on the first vertex of gray platform.
To begin with, I draw a gray platform with a perspective projection and set it using gluPerspective:
float fov = 69;
float aspectRatio = 960.0f / 480.0f;
float zNear = 0.1;
float zFar = 1000.0;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fov, aspectRatio, zNear, zFar);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(
    0.0f, 0.0f, 5.0f,
    0.0f, 0.0f, 0.0f,
    0.0f, 1.0f, 0.0f
);

Then, I will install an orthographic projection on the whole screen. The rendering starts from the upper-left corner of the window. My task is to draw a red square at the point where the first vertex of the gray platform begins to be drawn:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 960, 480, 0, 1, -1);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

drawRedRect(Project(glm::vec3(-1.0f, -1.0f, -1.0f), fov, aspectRatio, zNear, zFar));

Code for Project function:
float fov = tan(fovy / 2.0F);
glm::mat4x4 identity = glm::mat4x4(
    1.0f, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0,
    0, 0, 0, 1
);
glm::mat4x4 projectionMatrix = glm::mat4x4(
    fov / aspectRatio, 0.0f, 0.0f, 0.0f,
    0.0f, fov, 0.0f, 0.0f,
    0.0f, 0.0f, (zFar + zNear) / (zNear - zFar), (2.0f * zFar * zNear) / (zNear - zFar),
    0.0f, 0.0f, -1.0f, 0.0f
);

glm::mat4x4 lookAt = glm::lookAt(
    glm::vec3(0.0f, 0.0f, 5.0f),
    glm::vec3(0.0f, 0.0f, 0.0f),
    glm::vec3(0.0f, 1.0f, 0.0f)
);

glm::vec4 platformVector4 = glm::vec4(platformVector.x, platformVector.y, platformVector.z, 1.0f);
platformVector4 = projectionMatrix * lookAt * platformVector4;
//platformVector4 /= platformVector4.w;

float halfWidth = 960.0f / 2.0f;
float halfHeight = 480.0f / 2.0f;

glm::vec2 screenProjectedVector = glm::vec2(
    halfWidth + (platformVector4.x * 960.0f) * 0.5f,
    halfHeight - (platformVector4.y * 480.0f) * 0.5f
);

return screenProjectedVector;

I also tried to use float fov = tan(glm::radians(fovy / 2.0F));, but it didn't get successful result.
According to the formula used by gluPerspective, I calculated the fov and the perspective projection matrix:

Result of my code:

But I need the square to be on the first vertex, and it's unclear where.

You can cast a ray from the vertex point to the eye. Then based on the distance between camera and eye scale the dot. No need for orthographic projections.


text:
Unity AAB build breaks with "split application binary" checked
I am currently encountering a challenge similar to the one described by a fellow Unity developer in this forum thread.
I am using Unity version 2022.3.10f and configuring asset bundles while building my project with the 'split application binary' option. However, upon uploading the resulting .aab file to the Google Play Console and attempting to play the game, I am experiencing a critical issue. It seems that the game is not retrieving essential assets, scripts, and texts from the obb file.
What's interesting is that when I build the project without the .aab format (creating an APK instead), the issue persists. Even though the obb file size is 1.2GB, the APK size is only 60MB.
I have applied a temporary fix by manually moving the obb file to the 'android/obb/(gamepackagename)' folder on the device for the non-AAB build (APK build), and the issue is resolved. However, this is not a sustainable solution.
I am seeking a permanent fix for this issue with AAB builds. Any insights or guidance on how to address this matter would be greatly appreciated.

This is a cross post from StackOverflow where the question has been closed for not including enough details to reproduce or debug the problem. Reposting the same question without adding this information will lead to the same result.


text:
clion.sh does not exist
I have Unreal Engine in Linux launched with ./UnrealEditor
This file here Linux_Unreal_Engine_5.3.0/Engine/Plugins/Developer/CLionSourceCodeAccess/Source/CLionSourceCodeAccess/Private/CLionSourceCodeAccessor.cpp contains a default path for CLion which is  /opt/clion/bin/clion.sh but mine is somewhere else in snap/.
I used to just write clion in the terminal under snap/ and CLion get started.
so I wanted to modify that c++ file but I do not have clion.sh, as I said I just started it with clion.
So I changed it to /home/$USER/snap/clion
When I launched Unreal Engine 5.2 and tried to open CLion from the  menu. I still cannot launch CLion.
Can someone help with this?


text:
Specular lighting does not appear
I'm struggling to add specular lighting on-top of diffuse lighting and not entirely sure where I'm going wrong.  I've followed the instructions given in our lecture but it just doesn't seem to be appearing on-top at all.

light_vs.hlsl
// Light vertex shader
// Standard issue vertex shader, apply matrices, pass info to pixel shader
cbuffer MatrixBuffer : register(b0)
{
    matrix worldMatrix;
    matrix viewMatrix;
    matrix projectionMatrix;
};

cbuffer CameraBuffer : register(b1)
{
    float3 cameraPosition;
    float padding;
};

struct InputType
{
    float4 position : POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
};

struct OutputType
{
    float4 position : SV_POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
    float3 worldPosition : TEXCOORD1;
    float3 viewVector : TEXCOORD2;
};

OutputType main(InputType input)
{
    OutputType output;

    // Calculate the position of the vertex in the world
    float4 worldPosition = mul(input.position, worldMatrix);
    output.viewVector = cameraPosition.xyz - worldPosition.xyz;
    output.viewVector = normalize(output.viewVector);

    // Calculate the position of the vertex against the world, view, and projection matrices.
    output.position = mul(input.position, worldMatrix);
    output.position = mul(output.position, viewMatrix);
    output.position = mul(output.position, projectionMatrix);

    output.worldPosition = mul(input.position, worldMatrix).xyz;

    // Store the texture coordinates for the pixel shader.
    output.tex = input.tex;

    // Calculate the normal vector against the world matrix only and normalise.
    output.normal = mul(input.normal, (float3x3) worldMatrix);
    output.normal = normalize(output.normal);

    return output;
}

light_ps.hlsl
// Light pixel shader
// Calculate diffuse lighting for a single directional light (also texturing)

Texture2D texture0 : register(t0);
SamplerState sampler0 : register(s0);

cbuffer LightBuffer : register(b0)
{
    float4 ambient;
    float4 diffuse;
    float3 position;
    float padding;
    float specularPower;
    float4 specular;
};

struct InputType
{
    float4 position : SV_POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
    float3 worldPosition : TEXCOORD1;
    float3 viewVector : TEXCOORD2;
};

// Calculate lighting intensity based on direction and normal. Combine with light colour.
float4 calculateLighting(float3 lightDirection, float3 normal, float4 ldiffuse)
{
    float intensity = saturate(dot(normal, lightDirection));
    float4 colour = saturate(ldiffuse * intensity);
    return colour;
}

float4 calcSpecular(float3 lightDirection, float3 normal, float3 viewVector, float4 specularColour, float specularPower)
{
    // blinn-phong specular calculation
    float3 halfway = normalize(lightDirection + viewVector);
    float specularIntensity = pow(max(dot(normal, halfway), 0.0), specularPower);
    return saturate(specularColour * specularIntensity);

}

float4 main(InputType input) : SV_TARGET
{
    // Sample the texture. Calculate light intensity and colour, return light*texture for final pixel colour.
    float4 textureColour = texture0.Sample(sampler0, input.tex);
    float3 lightVector = normalize(position - input.worldPosition);
    float4 lightColour = ambient + calculateLighting(lightVector, input.normal, diffuse);

    float4 specularColour = float4(1.0f, 1.0f, 1.0f, 1.0f);
    float specularPower = 512.0f;
    float4 specular = calcSpecular(lightVector, input.normal, input.viewVector, specularColour, specularPower);

    return (lightColour + specular) * textureColour;
}

what are your specular values?


text:
Launch4J wrapped jar produces JNILibLoaderBase errors
I created an executable jar file bundled with JOGL, then wrapped the jar into a windows executable using Launch4j in order to pass runtime java parameters. If I run the jar from a command prompt I get no errors. If instead I run the Launch4J executable I get the errors shown below, but the application nevertheless runs properly, displaying the correct graphics. So, the problem seems to lie with the Launch4J executable and not the executable jar.
Is there someway to prevent the errors that only occur when running the Launch4J executable?
JNILibLoaderBase: Caught IllegalArgumentException: No Jar name in <jar:file:/C:/temp/BombsightApp20231130.exe!/jogamp/common/Debug.class>
JNILibLoaderBase: Caught IllegalArgumentException: No Jar name in <jar:file:/C:/temp/BombsightApp20231130.exe!/jogamp/nativewindow/Debug.class>
JNILibLoaderBase: Caught IllegalArgumentException: No Jar name in <jar:file:/C:/temp/BombsightApp20231130.exe!/jogamp/nativewindow/Debug.class>
JNILibLoaderBase: Caught IllegalArgumentException: No Jar name in <jar:file:/C:/temp/BombsightApp20231130.exe!/jogamp/nativewindow/Debug.class>


text:
When does normalization happen in the perspective projection matrix
I am currently watching this video where the instructor shows how the perspective project matrix is actually derived.
There are a few things that I am still unclear of. Firstly he says we need to normalize the coordinates between -1 and 1. However I do not understand where that happens or how that even happens.
I understand what normalization means however in this context I am completely lost.
Secondly I do not understand how the multiplying \$1/tan(θ)\$ with both the x and y coordinates helps.
The only part that I understood was multiplying that aspect ratio with the x coordinate.
If anyone could clear this up I would appreciate it.


text:
How can I reduce beam intensity without significantly reducing light brightness?
I picked up Unreal 5.0 last week and don't what question to ask the oracle Google to help me fix the problem.
This is what I have. (ImgA)

This is the look I am trying to get. (ImgB)

I started with the basic level layout for my project in ImgA. I want to get the lighting look in ImgB with is from the DMX starter project. What do I need to change or add to my project to get the look I want?


text:
Unreal 5 Strange Global Illumination Effects
As stated in the title, I am having some strange effects with global illumination. I am using Lumen, and I have no active post process volumes (I have one which is set to "editor only")
I have a player actor with a spotlight attached to the blueprint, set to 20 lumens (I have tried playing with the lumen value, but it doesn't seem to change the effects) and am having weird issues with the lighting.
In this video, you can see that when you look up a bit, the lighting appears to dim, which is the opposite of what I would expect (I would expect the global illuminator to get brighter, as there are less surfaces "reflecting" light back to the camera)
I have also noticed that while looking up, as in the video, if you back up (same camera angle) so that a closer ceiling is within view, it will brighten again.
How can I fix this unexpected behavior?
Please let me know if there is any other information needed.


text:
Is this gimbal lock I'm hitting even with rotation matrices / quaternions?
I'm spawning a trigger box relative to another object using local offset. The engine I'm using does not provide a native function to make that conversion (at least in a way accessible to me), so I am performing the conversion from local offset to world coordinates manually. The engine provides world rotation of objects in Euler angles, which is subject to gimbal lock, so I'm using the 3x3 rotation matrix from the object's transform instead.
However, I still seem to be experiencing what I believe is gimbal lock even when using the 3x3 rotation matrix rather than Euler angles. Normally when I have an object only rotated on one or two axes, the trigger is spawned correctly (in the "push" position of the lever):

However, there are certain rotations where local to world space conversion gets confused and the trigger does not spawn in the right location.

The trigger spawns near the center of the lever rather than in the desired location. Those levers' world rotations (from nearest to furthest from the camera) are:

X=0, Y=-36, Z=32 degrees
X=0, Y=-36, Z=-32 degrees
X=0, Y=36, Z=32 degrees

Even though I am not using Euler angles to compute the local->world transformation, it looks like this is still gimbal lock? Is that accurate, or is there another error that could cause this? The code I am using to make the transformation:
struct Quaternion {
    double w, x, y, z;
};

Quaternion matrixToQuaternion(const RE::NiMatrix3& m) {
    Quaternion q;
    double trace = m.entry[0][0] + m.entry[1][1] + m.entry[2][2];

    if (trace > 0) {
        double s = 0.5 / sqrt(trace + 1.0);
        q.w = 0.25 / s;
        q.x = (m.entry[2][1] - m.entry[1][2]) * s;
        q.y = (m.entry[0][2] - m.entry[2][0]) * s;
        q.z = (m.entry[1][0] - m.entry[0][1]) * s;
    } else {
        if (m.entry[0][0] > m.entry[1][1] && m.entry[0][0] > m.entry[2][2]) {
            double s = 2.0 * sqrt(1.0 + m.entry[0][0] - m.entry[1][1] - m.entry[2][2]);
            q.w = (m.entry[2][1] - m.entry[1][2]) / s;
            q.x = 0.25 * s;
            q.y = (m.entry[0][1] + m.entry[1][0]) / s;
            q.z = (m.entry[0][2] + m.entry[2][0]) / s;
        } else if (m.entry[1][1] > m.entry[2][2]) {
            double s = 2.0 * sqrt(1.0 + m.entry[1][1] - m.entry[0][0] - m.entry[2][2]);
            q.w = (m.entry[0][2] - m.entry[2][0]) / s;
            q.x = (m.entry[0][1] + m.entry[1][0]) / s;
            q.y = 0.25 * s;
            q.z = (m.entry[1][2] + m.entry[2][1]) / s;
        } else {
            double s = 2.0 * sqrt(1.0 + m.entry[2][2] - m.entry[0][0] - m.entry[1][1]);
            q.w = (m.entry[1][0] - m.entry[0][1]) / s;
            q.x = (m.entry[0][2] + m.entry[2][0]) / s;
            q.y = (m.entry[1][2] + m.entry[2][1]) / s;
            q.z = 0.25 * s;
        }
    }

    return q;
}

RE::NiPoint3 rotateQ(const Quaternion& q, const RE::NiPoint3& v) {
    RE::NiPoint3 u = {(float)q.x, (float)q.y, (float)q.z};
    RE::NiPoint3 uv = {u.y * v.z - u.z * v.y, u.z * v.x - u.x * v.z, u.x * v.y - u.y * v.x};
    RE::NiPoint3 uuv = {u.y * uv.z - u.z * uv.y, u.z * uv.x - u.x * uv.z, u.x * uv.y - u.y * uv.x};

    return v + ((uv * (float)q.w) + uuv) * 2.0f;
}

RE::NiPoint3 localToWorld(RE::NiPoint3 localOffset, RE::TESObjectREFR* relativeTo) {
    // Get object's rotation matrix and convert it to a quaternion for easier use
    RE::NiTransform transform;
    relativeTo->GetTransform(transform);
    Quaternion q = matrixToQuaternion(transform.rotate);

    RE::NiPoint3 rotatedOffset = rotateQ(q, localOffset);
    return relativeTo->GetPosition() + rotatedOffset;
}

For reference, I'm using the Creation Engine whose axial implementation (according to these docs) is:

Extrinsic, left-handed angles applied in the order of Z, Y, and then X
X+ is right, Y+ is forwards, Z+ is up

and I've noticed that even using an Euler angles transformation that applies the angles in the right order still hits this problem. Papyrus function adapted from here:
float[] function GetPosXYZRotateAroundRef(ObjectReference akOrigin, ObjectReference akObject, float fOffsetX, float fOffsetY, float fOffsetZ)
        ; flip angles since it's left-handed
        float fAngleX = -akOrigin.GetAngleX()
        float fAngleY = -akOrigin.GetAngleY()
        float fAngleZ = -akOrigin.GetAngleZ()

        float myOriginPosX = akOrigin.GetPositionX()
        float myOriginPosY = akOrigin.GetPositionY()
        float myOriginPosZ = akOrigin.GetPositionZ()

        float fInitialX = fOffsetX
        float fInitialY = fOffsetY
        float fInitialZ = fOffsetZ

        float fNewX
        float fNewY
        float fNewZ

        ;Objects in Skyrim are rotated in order of Z, Y, X, so we will do that here as well.

        ;Z-axis rotation matrix
        float fVectorX = fInitialX
        float fVectorY = fInitialY
        float fVectorZ = fInitialZ
        fNewX = (fVectorX * Math.cos(fAngleZ)) + (fVectorY * Math.sin(-fAngleZ)) + (fVectorZ * 0)
        fNewY = (fVectorX * Math.sin(fAngleZ)) + (fVectorY * Math.cos(fAngleZ)) + (fVectorZ * 0)
        fNewZ = (fVectorX * 0) + (fVectorY * 0) + (fVectorZ * 1)

        ;Y-axis rotation matrix
        fVectorX = fNewX
        fVectorY = fNewY
        fVectorZ = fNewZ
        fNewX = (fVectorX * Math.cos(fAngleY)) + (fVectorY * 0) + (fVectorZ * Math.sin(fAngleY))
        fNewY = (fVectorX * 0) + (fVectorY * 1) + (fVectorZ * 0)
        fNewZ = (fVectorX * Math.sin(-fAngleY)) + (fVectorY * 0) + (fVectorZ * Math.cos(fAngleY))

        ;X-axis rotation matrix
        fVectorX = fNewX
        fVectorY = fNewY
        fVectorZ = fNewZ
        fNewX = (fVectorX * 1) + (fVectorY * 0) + (fVectorZ * 0)
        fNewY = (fVectorX * 0) + (fVectorY * Math.cos(fAngleX)) + (fVectorZ * Math.sin(-fAngleX))
        fNewZ = (fVectorX * 0) + (fVectorY * Math.sin(fAngleX)) + (fVectorZ * Math.cos(fAngleX))

        ;Return result
        float[] fNewPos = new float[3]
        fNewPos[0] = fNewX + myOriginPosX
        fNewPos[1] = fNewY + myOriginPosY
        fNewPos[2] = fNewZ + myOriginPosZ
        return fNewPos
endFunction

I'm slightly skeptical that this is gimbal lock since it happens both with a rotation matrix transformation & Euler angles applied in the correct order, but I'm not an expert in linear algebra. Is this gimbal lock, or some other issue? Is there a way to work around it?

Why convert to a quaternion at all rather than transform the vector by the matrix directly?


text:
Godotsteam initialization on Linux
I have a problem in getting godotsteam running on my linux OS (Zorin OS).
Here is what I have done so far:

I have downloaded godosteam addon for using it on godot 4.1.2 from the github official page

created an account on Steam and logged in Steamworks but not paying the 100$ fee

downloaded steam and running it on my pc while working on Godot

created new steam_appid.txt (writing 480 as in documentation)

wrote these 2 lines inside main script:
var err = Steam.steamInit()
print(err)

But, here is the output I get:
{ "status": 20, "verbal": "Steam not running." }

What could be a possible solution to this problem?


text:
How to draw a tile placement grid in a 2d isometric place/world?
I'm working on an isometric 2d tile based game in ruby using SLD 2. The tiles are 40px wide and 20px tall. I'm trying to figure out how to draw the grid (where each cell of the grid is a potential tile, and a tile will be able to be placed there in the map editor).
Normally when making a tile based game, to draw the grid, I would first draw the vertical lines, iterating from 0 to the screen width, in multiples of the tile width. Then I would iterate from 0 to the screen height, in multiples of the tile height, drawing horizontal lines at each iteration along the y axis.
I'm lost as to how I should draw this in an isometric world. I have a function to convert cartesian coordinates to isometric coordinates, and vice versa.
The first thing I tried was to draw the grid as if it was a normal top-down cartesian grid, and right before drawing it, I converted the starting position of the line, and the ending position of the line, to isometric coordinates. This actually worked, however the grid is shifted significantly, and doesn't cover much of the screen:

I'm thinking there are two things I could do. The first thing would be to calculate how far off these lines are from [0, 0], and then shift each line by that difference, and do the same with the horizontal lines. That might help cover more of the screen, and then I'd probably also need to keep drawing additional lines (roughly twice the screen width and height respectively?).
The second idea I have, would be to simply calculate the angle at which this isometric projection happens at (basically two pixels of horizontal movement for every single pixel of vertical movement), and then just draw a bunch of these lines at an angle. However I think it would be really hard doing it this way to figure out where to place the tiles.
However, I'm sure there is a correct way to do this, and that's why I've come here, I'd really like to do this the correct way, and would appreciate any help.
Thanks.


text:
Pass texture array into shader and paint mesh vertices depending on vertexattributes
Well,
I'm a newbie with shaders, I'm just trying to paint a mesh depending on the vertex attribute passed with one or another texture.
The idea is to achieve this, for example:

For this, I have been reading some documentation.
So, if I understand fine, I need a vertex subshader with the following structure:
        struct Input
        {
            float2 uv_MainTex;
            float arrayIndex;
        };

Then pass its information from the vert out parameter of type Input, to be used in the surf shader as an Input IN param:
        void vert(inout appdata_full v, out Input o)
        {
            o.uv_MainTex = v.texcoord.xy;
            o.arrayIndex = v.texcoord.z;
        }

        void surf(Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = UNITY_SAMPLE_TEX2DARRAY(_Top, float3(IN.uv_MainTex, IN.arrayIndex)) * _Color;
            o.Albedo = c.rgb;

            // Metallic and smoothness come from slider variables
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = c.a;
        }

The full code of the shader:
Shader "Custom/z3nth10n/MultiTriplanar"
{
    Properties
    {
        _Top("Top Main Texture", 2DArray) = "" { }
        _Color("Color", Color) = (1,1,1,1)
        _Glossiness("Smoothness", Range(0,1)) = 0.5
        _Metallic("Metallic", Range(0,1)) = 0.0
        _ZOffset("Z Buffer Offset", Float) = 0
    }

    SubShader
    {
        Tags { "RenderType" = "Opaque" }
        LOD 200
        Offset[_ZOffset],[_ZOffset]

            CGPROGRAM
        #pragma surface surf Standard fullforwardshadows vertex:vert
        #pragma vertex vert
        #pragma require 2darray

        struct Input
        {
            float2 uv_MainTex;
            float arrayIndex;
        };

        UNITY_DECLARE_TEX2DARRAY(_Top);

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;

        void vert(inout appdata_full v, out Input o)
        {
            o.uv_MainTex = v.texcoord.xy;
            o.arrayIndex = v.texcoord.z;
        }

        void surf(Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = UNITY_SAMPLE_TEX2DARRAY(_Top, float3(IN.uv_MainTex, IN.arrayIndex)) * _Color;
            o.Albedo = c.rgb;

            // Metallic and smoothness come from slider variables
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = c.a;
        }
        ENDCG
    }
        FallBack "Diffuse"
}

This is the full project: https://drive.google.com/file/d/1wJ9QyvkSA_rBAXfN1rFowDpWY5EhqEDV/view?usp=sharing
If you open the Custom/z3nth10n/MultiTriplanar shader you will notice that there is more code, I want to achieve tri-planar implementation with NativeArrays and VertexAttributes later, but now I'm focusing on this part.
As you can see the mesh is showing like this:

It has no tiling and any information has passed through the VertexAttribute Mesh Data Buffers.
Also, there is my implementation in C# to show you how I pass the vertex data to the mesh buffers:
using System.Linq;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.Rendering;

public class PlaneVerticesTest : MonoBehaviour
{
    [StructLayout(LayoutKind.Sequential)]
    private struct BiomeVertexLayout
    {
        public Vector3 texcoord;
    }

    public Texture2DArray texArray;

    // Start is called before the first frame update
    private void Start()
    {
        //var texArray = Resources.Load<Texture2DArray>("TextureArrays/Biome1DiffuseTextureArray");
        var textureCount = texArray.depth;

        var mesh = GetComponent<MeshFilter>().mesh;

        Debug.Log(SystemInfo.SupportsVertexAttributeFormat(VertexAttributeFormat.Float32, 4));

        var layout = new[]
        {
            new VertexAttributeDescriptor(VertexAttribute.TexCoord0) //, VertexAttributeFormat.Float32, 4)
        };
        mesh.SetVertexBufferParams(mesh.vertexCount, layout);

        var data = Enumerable.Range(0, mesh.vertexCount).Select(i => new Vector3(mesh.uv[i].x, mesh.uv[i].y, i % textureCount)).ToArray();
        mesh.SetVertexBufferData(data, 0, 0, mesh.vertexCount);
    }

    // Update is called once per frame
    private void Update()
    {
    }
}

As you can see I'm using var data = Enumerable.Range(0, mesh.vertexCount).Select(i => new Vector3(mesh.uv[i].x, mesh.uv[i].y, i % textureCount)).ToArray();
That means that per each vertex index, I'm just passing the same arrayIndex to the shader Input object (treating the textureCount part with a modulus operator).
Can anyone give me some guidance on this?


text:
How to prevent jarring collision resolution when enabling a ragdoll?
After enabling a rigid body and collider on an object that is overlapping with another object, it applies a large amount of force to the object, so it jumps out of the overlap.
The problem is worse when using a ragdoll. I use ragdolls for characters' death in a game. When their ragdoll gets enabled on death, if they're touching another object, the sudden correction stretches their joints and makes them jump, preventing them from falling smoothly.
I changed Solver Iterations and projection on joints to prevent jitter on ragdolls but they still have the collision problem on when they get enabled.
I need to know what is a good solution for this problem. Maybe I can consider them as triggers and check if they're in a collision with another object before turning the collision when the ragdoll behaviour starts, but that might not be a performant approach.


text:
LibGDX Table rendering order draw calls
I'm using LibGDX Table for drawing some simple structure but I am having problem with draw calls and texture binding handling.
For clarification, I have a TextureAtlas loaded and I can get the following textures from it. And then I have a Table with following structure:
table.add(new Image(textureAtlas.findRegion("region1")))
table.row()
table.add(new Image(textureAtlas.findRegion("region2")))
table.row()
table.add(new Image(textureAtlas.findRegion("region3")))

In this case, it renders the table with only one draw call and one texture binding, as all the texture regions belongs to the same loaded Texture.
But now, if I create a table interleaving with another Actor, like this:
table.add(<some actor>)
table.add(new Image(textureAtlas.findRegion("region1")))
table.row()
table.add(<some another actor>)
table.add(new Image(textureAtlas.findRegion("region2")))
table.row()
table.add(<some another actor>)
table.add(new Image(textureAtlas.findRegion("region3")))

The texture regions are not drawn in sequence as before, it's necessary a new draw call / texture binding for each one of the three texture regions from textureAtlas.
I short, if I draw the three texture regions in sequence, one after the other, it uses only one draw call and texture binding. Otherwise, if there is something else in the middle, it uses a new draw call and texture binding for each texture region, even if they are part of the same texture.
My question is, is there any way I can re-arrange the Table's drawing order, so I draw the texture regions one after the another, and only after I draw the another Actors? Even if my table has the visual structure I presented above? Or do I need to create a custom Table class for handling this properly?
One thing I've already tried was to use table.getChildren(). This returns a list of the table's children Actors. And I tried to draw the elements from this list in the order I want, but they are not positioned correctly (always at position (0,0)). I also tried to recreate this children list with the order I want, but I cannot do table.setChildren().


text:
Interface in UE5 not casting or working as a variable
In UE5.3.2, I have created an interface in C++ (code at the end) that I'm trying to implement in a Blueprint. The editor gets the type correctly, and I have been able to make a simple implementation:

The implementation is a blueprint Object named GoldCpp. However, I can't use this type or I can't cast it:

The cast always fails (and prints false), and the "default value" for the ItemInterface shows no options. What am I missing?
// This class does not need to be modified.
UINTERFACE(MinimalAPI, Blueprintable)
class UItemInterface : public UInterface
{
    GENERATED_BODY()
};

/**
 *
 */
class LASTWORLD_API IItemInterface
{
    GENERATED_BODY()

    // Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
  UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
    UStaticMesh * GetMesh();
};


text:
Raycasting unable to detect water layer
I'm having issues detecting the ocean in my Unity scene (screenshot below) using Raycasting. In the image below, I've attached my script to a child object and set the layer for the Ocean object to Water.

The code looks something like this:
[SerializeField]
private Transform playerPosition;
private float detectionFeelers = 2f;

// Update is called once per frame
void Update()
{
    RaycastHit hit;
    Vector3 raycastOrigin = playerPosition.position;

    //tried LayerMask.GetLayer("Water") and using
    if (Physics.Raycast(raycastOrigin, Vector3.down, out hit, detectionFeelers, 1<<4))
    {
        // Player is near the water
        Debug.Log("Player is near the water! Hit object: " + hit.collider.gameObject.name + " Distance: " + hit.distance);
    }

}

private void OnDrawGizmos()
{
    Vector3 gizmoPosition = transform.position;
    Gizmos.color = Color.red;
    Gizmos.DrawRay(gizmoPosition, Vector3.down * detectionFeelers);
}

I've also tried selecting the layer for the Physics.Raycast function by using the dropdown option and by getting the layer by using GetLayer(), and I've given the ocean object a mesh collider as well but nothing works. I just can't detect proximity to the ocean.
Any help would be much appreciated.


text:
having problems packaging my game in UE 5.3.2
I have tried to package my game and it doesn't work.
I am unsure how to proceed any further. It was a week ago or so that I started trying to package my game in 5.3.2 but that didn't work. Upon investigation, I discovered that when I use a game instance upon reopening the UE editor, it crashes. So I have been working very hard to replace game instance with save game. But tonight just for kicks. I tried to package my, without game instance. And the same cryptic error that happens every when the game instance crashes the editor happened in package.
I had thought this error is caused by presence of game instance so I was just testing to see ok what if there is no game instance would my game package, sadly the answer is NO.
Both my crash log and the package error log share the same cryptic error whose meaning have not been able to find in all my searches online.
The error is:
Assertion failed: Linker [File:D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2152]

So I went and downloaded the debugging symbols. so this time the package failing log is much more explicit, here is the complete log.
The full crash log after using game instance upon reopening the UE editor.

So I went and downloaded the debugging symbols. so this time the package failing log is much more explicit, here is the complete log.
https://drive.google.com/file/d/1ALs09cpq9AXe7RX7KE2abcDT6Ipz6sbe/view?usp=drive_link


text:
How to make 2D Customizable Pixel Animation
I’ve looked around and can’t seem to find an answer on how people animate 2D pixel sprite animation that allows for customization. Let’s use Stardew Valley as an example since it’s popular and does what I’m talking about.
So far I have tried using multiple sprites for each body part but that proved to be not as customizable as I thought without needing to animate every possible combination.
I’m currently using a shader I wrote that uses two sprite sheets that work together using UV coordinates for the shader. This has been great, because it allows me to create one animation for each animation I need, then I can change the one of the sprite sheets and the shader will change the animations to the correct image I need.
This works for dynamic changes to the player’s appearance and I can even use the same shader for every NPC, then just change the sheet for that NPC to look how I want them.
Unfortunately, although I can change the appearance, I can’t make the character any other shape. For example if I need them to wear gauntlets or armor, the armor would have to stay within the bounds of the character, because my shader can only alter the colors used.
So what the best way to approach this, or better yet how is it being done?

Does this answer your question? How to animate sprite swapping with changeable equipment sprites?