Testing in Unity3d – Part 1

I don’t like writing tests. Do you? Well, ok, what I actually mean is that I don’t like writing unit tests. In one of my projects the assumption (and TeamCity setting) was that we’ll have 100% test coverage. There was no .net core yet, so we couldn’t write functional tests actually checking the integrations between different parts of the system and therefore we had to mock them. Oh boy, and we mocked them hard! Because of the requirement to have 100% of the code covered by tests, we had many tests doing no more than checking those mocks, because some methods were only reaching to multiple microservices and the results aggregation was done one layer above that. That’s what you get in most big enough codebases and our client wasn’t really keen on refactoring. So yep, I hated that period of time in my career (it’s actually just a tip of an iceberg, but that would be a topic for another, long post 😉 ).

Continue reading “Testing in Unity3d – Part 1”

Checking if a Transform is behind another Transform in Unity3d

The title is a bit misleading, because what I’m actually trying to figure out today is if a Transform sees another one from behind. The reason why I used this title is because I saw a lot of people asking questions formulated like the topic of this entry when they were actually trying to find a way to check if their game characters saw the backs of their opponents. The most popular SO / Unity forum answers only mentioned the Vector3.Dot method which is insufficient in this case.

Continue reading “Checking if a Transform is behind another Transform in Unity3d”

RPG – like formation algorithm

Well, it’s about time I wrote something Unity-related, eh? This time, from the depths of my disk, I’m pulling out a thing called a formation algorithm. For the sake of simplicity it’s designed for a team of three characters. Ok, you got me – for the sake of simplicity and also because that’s how I’m doing it in my amateur project 🙂

Continue reading “RPG – like formation algorithm”