Tree-Based Turret Model and Ground Turret Weapon Scripting

Tree Turret

I haven’t gotten all that much done on Super Space Trooper this weekend, though there has been a little progress.  Recently, I have written about the Leweria level that I am currently focusing on, and also posted a speed modeling video of a turret gun too.  Two days ago I began on the tree-based turret which will be a smaller gun with an animation sequence that occurs upon the player approaching.  Basically it will “fold” out of the tree its attached to, point towards the player and start shooting at them.

Animation Woes

I’m constantly having difficulties with Unity3D’s animation system.  I find that sometimes it will wrap (rotation) in unexpected ways.  For example, an X rotation of 0 on keyframe 0 and an X rotation of 90 on keyframe 10 may result in the object instead of going 0 to 90 degrees going 0 to -270 degrees instead.  After struggling with this for some time, I finally managed to get the turret’s animation sequence working in a satisfactory way.  From there, I added in my existing scripts to the gameObject and it’s children so that it wakes up upon player’s approach, performs weapons fire, exploding on player destroying it, and the player dying if they run into it.

Super Space Trooper - Ground Based Turret

Super Space Trooper – Ground Based Turret

Scripting for Ground Turret

I then moved on to script the motions of the ground based turret and set up its animation sequence.  The turret begins off under ground.  As the player approaches it moves up above ground, rotates to locate the player and begins to attack.  The animation sequence itself was quite simple, taking only about 20 minutes or so.  The scripting still needs to get done.  Here is my expected approach.

  • Follow player’s motion but clamp the rotation to just one axis, along the horizontal.  This will be used by the spinning section of the turret
  • Like above, follow the player’s motion but clamp the rotation to just one axis, this one along the vertical.  This will provide the up and down motion of the gun itself
  • With the two above, I will have a turning based for the gun and the gun will rotate up and down, accounting for about 180 degrees rotation horizontally and probably 90 degrees rotation vertically.

Once I get this finished up and tested, I’ll probably release the source code for others to use.

Posted in Super Space Trooper, Video Game Development

Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>