Sunday, March 26, 2017

TOE week 30: 85% is not enough for my wife



I didn’t have the most productive week. I did find a super cool bug when two teleporters overlap it sends the player’s position into oblivion and then fall until forever. No time to fix that however as I’m working on other things. Time was eaten up by breaking cars and other things. It wasn’t a terrible week though. I managed to put in artwork for all of the secondary weapons. The boomerang looks particularly cool IMHO. 

You know how an angry bird points toward the angle of its arc? Well I spent about a day trying to figure out just how to do that. The trouble with internet tutorials is that there is A LOT out there but not all of it applies directly to your specific situation. Like I could find out how to do this if you are trying to turn the Player facing based off of left analog input. I was almost to the point of asking a Unity Facebook group I am a member of. But then my wife called. We talked and I told her what I was trying to do and why it didn’t seem to work. She said ‘I know how to do that’.

She came home and wrote down part of an equation. She then bemoaned that she hadn’t used calculus in a while and didn’t hand me the equation. Then she had to work on her job stuff and the next morning she finished the equation showed me when I got up and then went to work. When my dad job was done I opened up the laptop plugged the equation as I understood it and it didn’t work. The Axe weapon just spun wildly and I was already doing that with the boomerang. Texted my wife she called and told me what I was doing wrong. I was using Tan instead of Atan. Hahahaha math! Switched it out and it worked…. Well mostly. 

The facing of the object I am rotating based on the angle doesn’t seemed to completely match the trajectory. But it is mostly right. Like 85% right. 85% was not enough for my wife. She considered this a failure. Personally from my POV this was 200% better than what I had two days before. It had game art and it appeared to face the direction of travel for the most part. Is this the behavior I would like to ship the game with? Hell no but it passes for now. 

For the truly curious and more math is fun friends of mine my wife’s equation looks like this in code:
toTangent = ((-4 * elapse_time) + (strengthY * speed));         angleOfMotionInRad = Mathf.Atan(toTangent) * playerFaceing * -1;           axeSprite.transform.Rotate(new Vector3(0, 0, angleOfMotionInRad));    
 
Also these 3 lines of code are far simpler than anything I could find online as to how you’re actually supposed to do this. So next time I’ll just ask my wife when I can’t get the boss AI right. Shouldn’t be a problem. 

Next week I hope to put in more artwork. Maybe I can put in some targets that are actually artwork. I also meant to add in a gateway artwork this week but didn’t have the time.

No comments:

Post a Comment