Saturday, January 28, 2012

Kart Racer- Winter Track Aesthetics + Yet Even Still More AI

First off [although not nearly as important], I've been experimenting with a few lighting concepts for the winter track. As you can see, I overhauled the lighting and skybox to a dusk setting [rather than mid-afternoon]. I really love the mood this sets, and it really helps the track stand out.














As for the AI, I've made some progress- the AI kart actually goes all the way around the track. Yep, that's right. Full 360.

In order to do it, I had to set up three targets around the track. The kart tracks to the first target and switches to the next once it gets within a certain distance. It will loop endlessly between the three targets, making it go all the way around the track.

However, the way in which I approached this wasn't my preferred method. I wanted to have just one steering actuator that would update the target automatically, but it always switched back to the previous target [and I couldn't figure out a system to prevent this]. Instead, I tried a state system in which it will switch to a new steering actuator in an independent state, thus [hopefully] preventing it from turning around. This eats up considerably more logic, though.

The system isn't perfect, as sometimes the kart won't think it reached the target and will turn back. It happens sporadically, so it's hard to tell exactly what's happening and how to fix it. Also, the system isn't versatile at all. I have the feeling that integrating this into the other tracks will be a nightmare. I don't have much time on my hands though, so it will have to do.

Also, I'm planning on getting screen capture software some time in the near future. This way I can actually post some footage of the AI in action. Just a heads up.

Saturday, January 7, 2012

Kart Racer- Audio Department and Yet Even More AI

Today I've started to work on some audio related aspects.

First off, I've added a crashing sound that will play when you bump into a wall. There's also a separate sound that plays when you crash into a tree [leaves rustling, etc.] I was hoping to trigger the sound only if the kart was traveling at a certain velocity before impact, but I couldn't get it to work properly. It seems fine the way it is.

Also, I've finished another track for the game. This will play at the main menu screen and at the results screen shortly after a race. I kept this one short, as the player won't hear it for too long anyway.



Next, I'm starting to conceptualize a system for when the player finishes three laps. Basically, the player kart will be swapped out with an AI kart after crossing the finish line, and the view will switch to a different camera that rotates 360 around the kart. This is when the menu track will fade in.

As far as artificial intelligence goes, I'm currently trying to figure out how to switch to the next target once it gets within a certain distance of the first target. Because the kart goes in a closed loop, it needs at least three or more targets placed around the track to go all the way around. That's it for now.

Tuesday, January 3, 2012

Kart Racer- Ignore that Last Post Regarding AI...

Well, I think I did it.

I already know that the steering actuator overrides all object movement- but I've finally thought of a system that compensates for this.

Basically, whatever calculates the steering vector must be a separate object from the kart, and also must constantly alternate between two states: one lets the steering actuator do its thing, and the other corrects it's position/orientation after the actuator moves it. This way, there's no conflicting movement that cancels out the steering actuator. This is done by a ghost object that won't render on-screen.

The ghost object alternates between its two states: in State 1, the steering actuator moves the ghost object and saves the steering vector as a variable [it saves this variable in a global directory so the Vehicle Wrapper script can access this value.]  In State 2, the ghost no longer calculates a path and aligns to the kart's worldPosition and worldOrientation. This way the steering vector in State 1 is accurate [well, not really, but close enough] to the kart's position. Upon returning into State 1, the ghost will update its path.

And it seems to work; although it's going to need a lot of tweaking to look natural. When the ghost object is resetting its position in state two, the steering vector reverts to zero- meaning that the kart's wheels will constantly straighten out every other logic tick. [which is, for those of you who don't know, about 30 times per second.]

It also seems to eat up a lot of logic- with this system running on one kart, the logic calculations jumped from 3% to about 8%- a 5% increase for each kart [basic math subtraction skills FTW!]. This doesn't sound like much, but once 5 AI karts are implemented, it will cost about 25% of total game calculations, which is a lot [one fourth, to be exact.] Hopefully I'll be able to modify and optimize the code to get this implemented and running smoothly.

Well, after seeing karts turning left for so long, it's awesome to see that AI is finally getting somewhere [more specifically, not left.] I shouldn't get too excited though, as there's still a lot ahead of me.

Wow, that's a big wall of text. I promise that the next post will have screenshots. Although I'm not promising anything. ;)


Kart Racer- AI Trouble

Okay, after testing out the steering actuator for quite a while, it seems that I simply can't integrate it with the vehicle wrapper. The actuator must be in charge of moving an object or else it won't return a steering vector.

Due to this,  I need to either find a completely different method to steer, or just scrap AI all together and focus on local multiplayer or a time trial mode.