FatNick Makes A Game: Part 4

Disaster Strikes! Having placed my MR2 into the action, I decided I wanted to add an extra camera into the max. As with pretty much everything in Unity, this was amazingly easy: I just dragged it onto my car object, dragged it around until it sat nicely on the bonnet, and that was that. The code to enable the code switching looked simple enough too. Essentially, I’d mapped the camera control to button “c” and, when pressed, i wanted it to enable whatever camera wasn’t and enabled and disable whatever camera was already enabled. Simple, really.

With the script attached, however, things went very weird very quickly. Suddenly, none of the scripts that worked a second before would cooperate, and my shiny new camera script was blathering about an incorrect class (even though JavaScripts in Unity are automatically given a class with their name.) It would appear that my entire project file was completely broken.

Given the situation, I did the worst thing anyone could probably ever do:I panicked. In my frenzied state, I tried to copy my latest backup over my live file, but ended up mixing my windows and accidentally overwriting my backup with the broken file instead. Yes folks, your author is a colossal moron.

If you yourself end up in this situation, DO NOT PANIC. It turns out there is a very simple solution: just remove the script that made everything else go a bit fruity, and everything else should return to normal. Oh, and once you’re back to normal, make a back up. And then back up the back up, just to be on the safe side.

make-agme

With my project repaired, I set my sights for the camera script a bit higher: Why just flip between two cameras when you could move ONE camera between two points, in the manner of the rather spiffy sega classic Virtua Racing? If it was possible in 1993, it should be possible now, damn it!

Unfortunately this one turned out to be a bit trickier than I first thought, to be honest with you. I thought I could achieve it with a clever hack of the default ‘smooth follow’ script by using a key to jump between two different ‘height’ and ‘distance’ parameters. Irritatingly, however, my camera wouldn’t move smoothly between the two points, and instead, decided to just sit at a weird height high above the car. I WILL come back to this at some point, but this idea is on the back-burner for now. Instead, I’ve simply reinstated bonnet cam and mapped the cameras to buttons 1 and 2. We’re good to go!

However, with the cameras set up. I still had some unfinished business with my worryingly unstable car handling. Though the anti-roll bar had worked well on the box car, for some reason my settings weren’t working with the MR2 at all. Possibly because it was significantly larger and wider.

make game

To resolve my handling problems, I tried a few things. I moved the wheels into the arches (they were sitting too far outside previously,) and altered the spring settings in the wheel colider’s suspension to make the whole thing a bit more solid. I also accidentally made an interesting discovery as far as drfit handling was concerned by messing with the sideways slip integar. I’ll definitely come back to that another day.

After moving my box coliders around again (i have a feeling they’re still a bit too far/behind the wheels) I made one final change to the center of gravity (closer to the middle, slightly lower) and I finally seem to have a drivable car again! Hurrah! I’m still not completely happy with it (I’m not sure why it pulls to the left..) but I’ve uploaded the physics test page with my progress. Why don’t you have a play?

(part 5)

One Reply to “FatNick Makes A Game: Part 4”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.