Showing posts with label Timing. Show all posts
Showing posts with label Timing. Show all posts

Sunday, October 13, 2013

Update 23: Alpha 1.6 - Lots of stuff finally released!

Alpha 1.6 has been released. This represents about 10 months of (part time) development, and is finally a little mini game. Admittedly a game without much depth, but still a game! Included in this release (since Alpha 1.5) are:

  • New cameras
  • Timing fixes all over
  • A very basic AI
  • New character models and animations
  • More dynamic explosions
  • Targeting indicators
  • More advanced stress testing
  • Links to the currently active test levels
  • And lots of little bug fixes


This is all pretty exciting to me, and I've started working on a story/theme for the next step, while I also add in some feature requests and refine some of the mechanics a little.

Try it out for yourself and let me know what you think!



Friday, September 27, 2013

Update 20: Alpha 1.56 - Timing

One of the biggest bugs in my code has been the timing of the camera movement, shooting and throwing. I've put off solving these problems for a variety of reasons, but with some early AI experiments, I found that it suddenly became essential to solve this immediately.

Fundamentally, the issues come from my usage of Coroutines, a Unity function that runs until it is finished. It's almost the same as creating a new thread. I use coroutines for my camera movement, shooting, throwing, and soon, for AI.

My game is simple, but still complex enough that I decided to create a separate  isolated test level to solve this problem. This little doodle shows my plan. I need two 'paddles', a ball to bounce back and forth, and the camera to switch between the two paddles between bounces. This functionality is all very similar to the way my camera follows a character taking their turn, and has them shoot/throw an object at an enemy.



With this design, my test looks like this:


I was able to easily try a few different tests, running through the 5 steps designed above, firing two projectiles instead of one, and really ensuring that the timing was working. I found that I could never get coroutines to wait. My bug was relatively simple (of course), and I've spent the last few hours actually refactoring the main branch of the code. Once this is working, I'll post about the AI.

Wednesday, September 4, 2013

Update 16: Alpha 1.4: Throwing

In the last few Alpha releases, I've been focusing on stabilizing the camera and shooting mechanics. I feel much better about how it all looks, especially the camera movement, with all bugs around the camera now addressed.

Although I have a few timing issues with the shooting still to solve, I've moved on to the next type of attack, throwing grenades. I started by working through the physics and showing the trajectory. 

With the help of two very important links:

  1. Some excellent theory from the Castle Story: http://www.sauropodstudio.com/dev-diary-number-eight/
  2. A script to draw the line from Unity3D wiki: http://wiki.unity3d.com/index.php/Trajectory_Simulation

Using this, I was able to calculate the distance to the target, based on a fixed angle of 45 degrees: this meant that I can throw my grenade in a nice parabolic curve towards the target. 

Here are two screen shots showing this in action in my test level, with the red line replaced by a trail of smoke: 

Just before the grenade hits...


Just after the grenade hits...


When my grenade collides against my target, it 'explodes'. At the moment it's just an expanding red sphere - particle effects to come later. I use the Physics.OverlapSphere() function to look for items within a certain radius:

Collider[] hits = Physics.OverlapSphere(myProjectile.transform.position, explosionRadius);


If any of my collider hits are a player, I deal damage, but if it's destructible terrain, I use the AddExplosionForce() function like this:

//If destructible terrain was hit, destroy it
if (hit.collider.tag == "DestructibleTerrain") 
{
    //Add Rigidbody to terrain/wall
    hit.transform.gameObject.AddComponent<Rigidbody>();
    
    //Add explosive force at the point of the projectile impact
    hit.transform.rigidbody.AddExplosionForce(explosionForce, myProjectile.transform.position, explosionRadius);
}

This has two effects: it removes the destructible terrain from the explosion area, and it propels the same terrain across the map, which I think is pretty cool...

You can download version Alpha 1.4 here: http://www.samsmithnz.com/content/tbe/tbe_alpha1.4.zip.