Friday, April 20, 2018

TOE week 56: Like a Dragoon I have returned!


I did a THING!

Not having touched this mammoth of a project in about 4 months and not have really worked on it 4 months before that, this week I decided to open it back up and try to do the most difficult coding task I have ever attempted. What is that you ask? It is an AI enemy that make different random decisions based on player actions. How did it go? Not good. Not because of the reason that you’re thinking.
AI was really grinding my gears before I stopped working on this but opening Unity and Visual Studio after VS had been dormant for months basically meant that it was broken upon opening. Like My project solution was no longer connected to my Unity project. Why did this happen you ask? TFIIK. Let us just say ‘because computers’ and be done with it. Long and short is that I had to NUKE VS 2015 and install VS 2017 and then coding could continue. But hey VS 2017 had a checkbox for Unity specifically so that is cool. 

On Tuesday I tried to make an enemy ray cast two different rays, high and low. If both hit do a thing if only low hit do a different thing and that was a swing and a miss. Basically wasted time. Monday and Wednesday both were spent drawing with some success. Thursday was the day I gave up on fighting with AI and I decided to make collision objects that simulate power conduction. I did this because I thought it would be easier than fighting AI the results are fifty fifty. 

I created a square that was the power source it is simply a box with the tag PowerSource. Then I have a different square tagged with Conductor. If a Conductor is OnTriggerStay (touching) an object that is PowerSource then the Flag on the Conductor flips to true for IsPowered. Sounds simple right? Wrong. One of my struggles in Unity is with objects that don’t know about each other talking to each other.

Simply in Unity you can send a message to two objects that are colliding but you can’t directly access the object. (Or if you can I don’t know about it.) Meaning that the Power Source knows nothing about the Conductor and vice versa. Let’s talk about a Conductor. If a Conductor is touching a Power Source on its left and it is ALSO touching a Conductor on its right. The Conductor in the middle sends a message to the Conductor on its right to flip IsPowered to true. Where it breaks down is when the power source is removed the Conductor loses power BUT the Conductor next to it then sends a message ‘hey buddy you are powered’ even though both are no longer connected. 

It should be noted that if there is only one Conductor object this all works correctly but a Conductor next to another Conductor has a bug. I will try fighting with it more after this update. So why have I done all of this? Because I wanted to create some power puzzles where the Player uses the portal to bridge a gap between Conductors. That works pictured below. Yellow blocks are Conductors, light Blue is Power Source, and Dark Blue is a Power Destination. 

 

Like pretty much now I guess. Oh and this is the picture of my main Character. 





No comments:

Post a Comment