Sunday, August 26, 2018

TOE week 62: Starting a Vertical Slice


Unity has two different functions basically built into it called OnTriggerEnter and OnTriggerExit. OnTriggerEnter sees if the edge of a collider is touching the edge of another collider and you can send a message. OnTiggerExit sends a message when two colliders stop touching. 

Last week I step up my Red Switches that activate when the Player Portal touches them. This works pretty well. EXCEPT when the Portal Collision contains the Red Switch entirely. The two objects are not touching because none of their edges meet. 

When I watched a Youtube video about how to be an indie dev it said that you don’t have to make all of your game objects to be completely 100% functional. The advice I received in my head basically said ‘you should probably move on to another thing’. However the fact that it wasn’t working was taunting me. I needed to solve this problem…. I am super bad about letting things go. 

So I decided to refine my red switch and make it function correctly because it should be activated when contained. However there is no function built in that does this I had to write my own. But that made me wonder why there isn’t a OnTiggerContained?

It really wasn’t that hard to build myself. It is basically just: PortalMeshCollider.bounds.Contains(redSwitch.transform.position). There is slightly more to it than that but after all of that was in my Red Switch was about a 100% better. Before I built my own version of this I tried making the Portal collision convex because I was under the impression that meant ‘not hollow’ BUT that didn’t work. 

After that I set up a Basic Switch. Very simply a switch that when struck by the player weapon it would move or rotate something. 

Most of this week was spent on making a vertical slice of the game. It isn’t anywhere close to completion. I was working on a vertical slice a while ago but I was building the level in blender and importing it into Unity but that was slow. Now I have switched over to probuilder. Much faster AND the editing is done in Unity so I do have to switch back and forth all of the time. I will probably have to use blender for the UVs when I get to the art portion of this but I’m not there yet still have to block this out. 

Also I made a video of what I made this week. 


Saturday, August 18, 2018

TOE week 61: the Hard Work that You Can't See


I have been feeling like working on this gargantuan project once again. Real talk I had been pretty depressed for a while and working on this just didn’t help with that. So I had been painting because that did help. Having a day job where people think your opinion matters and respect you for it DOES wonders for depression. Take two of that and call me in the morning. 

Also fighting with AI is still not something that I look forward to so working on THAT just didn’t feel worth it. With the time I’ve had on my two breaks though I could have probably put some of that to bed… That just makes me think about depressing thoughts all over again though so let’s stop talking about that. 

I only got to work on my game for about three days this week but the work that was done was still very productive. I wanted to make platforms that switch positions when the portal touched a switch object. I already had moving platforms but they didn’t have any code to stop moving so I kind of hacked them to do what I wanted with only a couple of bugs. Mainly that if the switch got hit too many times in a short period of time the start and end positions would basically flip.

I also had to make a switch manager that basically would flip its bool if any switch was hit and the switches would then all update. This was fairly easy once I remembered how to properly reference a script that wasn’t in the object. 

I finished it in about three hours and was pleased with myself.

Next day I created platforms that would rotate depending on if the player hit the switch. I had to ask for help on the Facebook Unity group I’m a member of to get this working. They didn’t actually help me but the interaction pointed me in the general vicinity of the problem. So I deleted everything a hacked in a crappy version that just added to the rotation value of the object every frame if the conditions were correct. It is a pretty crap solution to a problem that lerp should have addressed. Once it was working with my garbage fix I then deleted that fix and set up a solution using lerp and turns out I just needed to reset a variable for it to work correctly. 

I felt somewhat vindicated but silly that the result was almost exactly the same with just more control of the speed of rotation. 

Today I then looked back at my moving platforms and basically thought that I could make them work in the same way as the rotation I set up yesterday. Three or four hours later I basically had a bugless version of the thing I built two days ago. Again I redid work but the results are the same… 

Don’t get me wrong better code is always better but you would know it was different from looking at it.

This is what all of the work looks like.