Skip to main content

Posts

Showing posts from June, 2017

AI Controller Update - Week Ending 6/27

Now, this was a week in which some really important work was done. Last week, I wrote about the roadblocks I was facing with writing my own game engine – guaranteeing a smooth game loop, constant frame rate, and float precision. While it is quite easy to build a functional game loop, it is harder to build one that does not break under stress. Somehow my windows framework wasn’t sending regular updates to my main loop, and I spent quite a while scratching my head trying to figure it out. However, time is precious and it was running out. I had to make a decision, and make it quick. I chose to jump into Unreal and port over all my code into Unreal 4.16. Jumping to Unreal I wanted to build a follower behavior, but I also wanted to build it right. So, I made sure to have a component-based architecture from the get-go, and made sure to have the steering behaviors as Actor Components, so that they could be attached to any actor and be reused. The Actor Steering component...

AI Engine update - Week ending 6/20

This week, I worked on rendering objects with direction and velocity. The agent is rendered as a triangular object, which points at its current heading. The green line represents the velocity of the object. The text underneath represents the speed. I worked on additional behavior, which is the arrive behavior. Unfortunately I ran into a bug, where the velocity doesn't seem to be getting updated consistently. On further investigation, it turns out that the update loop was running so fast that the delta time between frames was turning up to be 0. What confuses me is that if the delta time is 0, then the agent shouldn't be moving at all, based on these lines: Vec2 Acceleration = SteeringForce / mMass ; mVelocity += Acceleration * deltaTime ; mVelocity . Truncate ( GetMaxSpeed ()); mPosition += mVelocity ; On further debugging, I discovered that the delta time is non-zero for the first few updates (suggesting that there was perhaps some setup code ...

AI Engine update - Week ending 6/13

This week, I worked on simple agent rendering: Rendering an agent as a simple circle. I also had to implement a Matrix, in which I had to implement different functions such as ·          Translate ·          Rotate ·          Scale ·          Transform This really helped with my 3-D math skills as I finally understood how to create, store and operate the above properties on a game object. After that, I worked on behaviors: Seek Given a target point, the agent will try to move towards that point. First, we calculate the direction we need to move in by subtracting our position from the target position, and normalizing it: Vec2 direction = Vec2 :: Normalize ( targetPosition - mpAgent -> GetPosition ()); We then calculate the velocity required by multiplying that by the max possible velocity o...