Fixing the Unity Constantly Turning or Spinning Player / Camera Problem

If your players are reporting that they keep spinning in your game and can’t stop, there might be an issue with the joystick inputs on their end that makes it impossible for you to find the bug. However… you can program to solve it if you make enabling Joysticks optional.

Here is a player video of the bug!

The best way to solve this from the programmer end is to write your input scripts to deal with it. Currently, your game (by default) accepts Horizontal and Vertical Axis info from the keyboard or a joystick. They are labeled the same in the Input Manager… That way you can write code like:

float translation = Input.GetAxis(“Vertical”) * speed;
float rotation = Input.GetAxis(“Horizontal”) * rotationSpeed;

And it won’t matter if the player is using a keyboard or a joystick. Unfortunately when a player has something going on with their joystick stuff (virtual joysticks seem to cause issues), the Axis gets all wonky… Players report spinning around that won’t stop.

BUT… If you change the name of your second set of Horizontal and Vertical Axes in the Input Manager (the ones that correspond to the joysticks) to something like HorizontalJoy and VerticalJoy then they won’t interfere for your keyboard-only using player. You could then add a toggle on your Controls or Pause menu to enable Joystick controls.

then you might write code like this:

if( !joystick )
{
//if joysticks aren’t enabled – just track keyboard axis

float translation = Input.GetAxis(“Vertical”) * speed;
float rotation = Input.GetAxis(“Horizontal”) * rotationSpeed;
} else

{

float translation = Input.GetAxis(“VerticalJoy”) * speed;
float rotation = Input.GetAxis(“HorizontalJoy”) * rotationSpeed;
}

Below is a screenshot of the input manager – notice the second set of Horizontal and Vertical Axis are called HorizontalJ and VerticalJ. Do something like that and write code to allow for joy support if you want to give your user the option and the bug should be fixed on your end and the users. This also means joys won’t really be tracked unless you write code to watch the specific axis as stated above. This solution worked for my testers.

Screen Shot 2014-12-01 at 7.08.51 PM

#1GAM Post-Mortem and November’s Game Vocab Stacker – Challenge Complete!!

Screen Shot 2014-11-30 at 7.55.27 PM

It’s been an entire year of making a game a month. I started on a snow day and made the Snowpacolypse snowball fight game and finally rounded it out with an educational project I am working on. I’ve delved into a number of spacey games, zombie shoot em ups, a 3rd person platformer, two somewhat abstract games, my first Android app that even sold some copies – Tap Invasion, 2 online multiplayer games, procedural generation maze game, and several (4!) Space Warfare demos.

Needless to say, I’ve experimented a lot and learned a lot. I feel happy about the things I’ve worked on and learned over the year and feel like a much better programmer! I am looking forward to the next year of focusing on just a few projects. Mainly my Space Warfare game and the educational games this months game is a sneak peak at. I have a lot of plans for Space Warfare and feel like it has come a long way. I hope to keep improving it and making it awesome after all the stuff I’ve learned.

Here is a link to the Badger Head Games One Game a Month Page…

 

The final game is part of a vocabulary game I am working on for my school. This is not the final version, just a demo version that is geared towards my Reading / English class. The final game is going to be focused on History vocab and will hopefully be released on school iPads!

Click here to play Vocab Stacker…

Dev Log: Space Warfare Infinite – Using Unity 4.6 UI for the HUD

 

The Unity 4.6 UI is really quite easy to use and it does not really on OnGui calls! I am adding some Data screens for the ship, just not sure what to put in there! Targeting info and ship status seem like the obvious choices. I like that you can make it look 3D so it feels like they are projected on the screen.

screen_70.66354

 

I like the immersiveness of cockpits, but I don’t like how they obscure your view of the action. I want players to be able to see the game and see what they are doing. I stared at the Privateer cockpit for a long time but that doesn’t mean it was the best way to see the game… I think I like the Elite method because its so open, but I like Star Citizen’s info panel design.

Key Features:

  • Better crosshair
  • Radar
  • Targeting
  • Ship / Shield Status
  • Systems Status
  • Enemy Target Info
  • Ammo / Fuel Status
  • Distance to waypoint

Inspiration screenshots:

Elite-hud

Elite’s HUD

 

starcitizenhud

Star Citizen HUD

privhud

Privateer HUD -not enough view!

Dev Log: Space Warfare Infinite – New AI tricks, missiles for everyone! and Unity3D Bloom findings

screen_78.26921Over the past week I’ve been having a lot of fun with Space Wars, while also researching and reading about AI. (I also got a little sidetracked by trying to perfect the bloom image effect….)

AI

AI can make a game like Space Warfare pretty exciting. I plan on having some multiplayer aspects once I get the major systems together, but the focus of the game is really a single player experience at this point. Since that is the case, cool AI pilots who behave in interesting manners is important. My actual AI code at this point needs to be refactored because it is a big mess, but the things its doing already even without a really nice organized OO state machine are pretty fun. I plan in the future to build out more of a Playmaker-esque state machine for these guys but it’ll take some focus. Because of the behaviors of the AI, the game is becoming pretty fun to watch. It has the enemies turn and loop and barrel roll to escape or ambush each other.

Current states include Chase, Attack, Reposition / Flee. Within those states the ships are able to barrel roll in reaction to being hit as well as change target focus. My idea is that I want to have some base states like Attack and then have a bunch of maneuvers that can be employed by the pilots depending on their style/personality/status. I am looking into multiple temporary short range ‘waypoints’ to create maneuvers so that AI can do looks or spiral at another ship instead of go in a straight line.

Some of my research to me to the above really cool video from Star Citizen (disclaimer: I am one man, Star Citizen will always be cooler than my game…). It hints how they are thinking about AI and displays some quick shots of the Ai engine. I can’t afford to hire that Ai company but I like some of their approaches. One of the things they really focus on is collision avoidance which made me think – oh man I don’t have anything to collide with yet other than really small ships better get to work on that! Unity’s Nav Mesh seems out because its a 2D plane and not a big open space. I’m heading towards a raycasting set up for individual ships. I forsee it being a little costly so I might have to add some collision radius objects that trigger the raycast steering only when necessary. One video that seems to explain the basics is here: http://vimeo.com/9304844. Sadly the author seems to have disappeared from the internet and never continued the series.

Missiles

I’ve also implemented missiles into the game. They are basically have perfect tracting to the only way to not get hit is to accelerate long enough that they can’t catch up or have them hit or get hit by something. I am working on a few countermeasures like a ‘chaff’ like drop and perhaps flares. I know chaff is for radar, but I might make it a dual purpose item in this game. It just drops a bunch of chunks of metal behind the ship that can clog an enemy radar with blips or set off a guided missile if a chunk collides with it. The other balancing option I will add is the length of time the guidance system works. This will give the player the ability to outrun then dodge a missile over a range if the guidance cuts out early, but is still a threat if the ship remains on the same course.

When I have add the ability to upgrade, ships could by better missiles with longer range guidance systems to make them harder to shake. As it stands now, unless your opponent launches a missile from too far away, the likely outcome is an explosion. Its so likely that for the above video I needed to disable missiles just to show you the Ai fighting without immediately creaming each other with missiles. Also I wouldn’t be able to stay in one place and film for my that 10 seconds before getting hit myself.

Missiles are a powerful weapon. But I always feel they are underpowered in games. Perhaps I should make it a little more random – 10% chance of surviving a missile? Perhaps its time to add shields!? Also individual parts of ships might mean less instant kills if its not a direct hit.

Bloom

On the Bloom front… well the game is shiny now! Look at the before and after!

 

screen_306.4306

Before…

screen_11.3738

After…

Things I’ve learned so far… some Unity image effects may be added after every camera is rendered. This means that no matter what camera you add an effect to, everything is gonna get the effect. The bloom happened on all my cameras no matter what my order was or culling set ups were. I’ve tried it all…. If someone out there reads this and finds out a way to make my findings untrue, I would love to see the solution! Comment, twitter, email me!

The main problem I’ve had is that the really nice Space for Unity scenes were getting over exposed and washed out so that you couldn’t enjoy the scenery. Since the main thing I wanted blooming were the trails and lasers, I ended up really brightening the particle materials they were using and then turning up the ‘threshold’ setting on bloom so that everything doesn’t wash out. It sort of works. I like more glowing than less so I am happy where I am with the look. Sometimes I feel like almost Bloom alone makes the Unity Pro license worth it — just the cool factor.

Dev Log: Space Warfare Infinite Updates -Bloom and Ai

I know I should be working on my November game, but the prospect of being able to devote more time to Space Wars (As well as finding a real game name for it – Space Warfare Infinite?) has been too tempting! I will get back to my monthly project soon, but  in the mean time lets talk updates to Spacewars.

Bloom –

Bloom is all the rage. It’s the main reason to get Unity Pro from what I can tell. That and the profiler. But lighting effects take your game and put it in the pro category – at least with the looks. I’ve been trying a bunch of different post-processing effects, but standard bloom seems to be the best for making space object look interesting and making laser flash and glow. The battle now just seems more alive! The downside is that brighter backgrounds glow too much and look too bright. At the moment I am just letting it slide. I fooled around with the camera render orders and such but could never get the bloom to only effect lasers. So far it doesn’t seem possible for me. (I did see someone wrote a shader that keeps bloom from rendering on something. I might do something like that someday to fix the nebulas and other stuff I don’t want to glow).

screen_11.3738

Ai –

I’ve also been futzing with the Ai. I really want to write behaviors and more decision making. The current Ai chooses a random target from a list of enemies and then blindly charges. When in range they start firing. The other behaviors include: if they get hit a couple time in rapid succession, they will find a random waypoint to run off to; if they are attacking for more than a few seconds they will find a new way point to back off and then go back to it; if they get hit by a ship that is not their target a few times, they will switch targets and defend themselves.

Last night I changed a few things that annoyed me. First I added a lead object to each ship so that ai will aim just before the target thus leading their shots. Works well for moving objects.

I want to build a behavior where the Ai does flybys or other maneuvers that make sense. As I step towards that, I removed their ability to stop. It looked super dumb to see ships just floating in space taking shots. I just have them thrust at all times now. I also dropped their rotation speed from 20 to 1 which makes them curve a little more when flying – looks more natural. No more turning to the player in a blink! I also want to add a behavior when they are too close for more than a few seconds, find a nearby waypoint to go to before attacking again — the ai seems to get in close and then circle the target without being able to aim shots. They need to be able to get a new attack vector. The movement makes the game much cooler looking. Everything circling around with trails.

Ai Behaviors I am hoping to put in:

  • Rush pass / loop: Ship flies by target attacking as they pass then pulls up and executes loops to do another run on same strike vector
  • Flanking loop to hit target from side Circle to get around and behind target Go to waypoint
  • Patrol series of waypoints
  • Follow / Protect target
  • Follow / Copy target (attack its targets) Stand still – cap ships will prob do this alot Kamakazi ramming
  • Strafe side – get up to speed then rotate to aim guns at target let inertia carry ship along side target while unloading weapons… (currently not possible in way game handles ship flight… but this might be an effective attack for fighters against a cap ships PDS)
  • Preferred targets – weakest, injured, toughest, untouched, ranged, fighter, cap, midrange, auxilery, stationary, slowest, low shields, low armor, high shields, high armor, no ‘type’ gun, specific ship
  • Scanning / Sight Range- how far should awareness go? Should be increased by auxiliary scanning ships in fleet.
  • Use specialized component – Scanner Jammer, EMP, Cloaking,

Live Streaming and Video Tutorials – Playing Strike Suit Zero on Twitch.tv

I’ve figured out how to set up a Twitch.tv account and how to do better screen cast videos on my computer. I hope to have better videos (HD) to show off future games. I also hope to start doing more How to Make Games tutorials for beginners on the web and my students. The Badger Head Games Twitch.tv channel is http://www.twitch.tv/badgerheadgames and my Youtube Channel is https://www.youtube.com/user/mikedolan03/videos. I’ll post relevant videos here, but you can subscribe to those channels as well.

As you will see from the video, while I love making games, I am not the best video game player! While I enjoy playing games, I also play stuff that I can get ideas from. The folks behind Strike Suit Zero have made a pretty impressive space battle game. I love the feeling of being in a big space battle with lots of fighters and capital ships flying around. The mission in the video also has a space station. I spend a lot of time trying to blow up a frigate and take lots of damage getting hit by its turrets. Each turret is targetable and destroyable. In my game, charging into Point Defense Turrets like that will probably make for a quick end to your ship. Taking out cap ships will require some strategic targeting of the defensive guns before making any type of bombing run.

Things I love about Strike Suit Zero:

  • Big cap ships engaging in battle
  • Nice small fish in a big fight feeling
  • Engine trails that make it easier to see enemies
  • Turrets on ships
  • Cool HUD targeting system – arrows pointing to available targets, boxes on targets, circle that tells you you are aiming right
  • nice explosions, shield effects, player hud static effects when damaged.
  • Comms w headshots  – moves story along with cinematics
  • Being able to survive but still lose a mission (sometimes the game doesn’t continue on tho, you have to play until victorious)

Anyway, look forward to my future videos. I am planning to make an intro to Unity tutorial featuring hover tanks and rockets. It should be an ‘easy’ to follow tutorial to get folks started on making their own Unity games.

Space Wars Team Battle Demo is Here

The month of September was devoted to experimenting with procedurally generated space areas, hyperspace jumping, and dog fighting AI.

The result is affectionately named Space Wars Team Battle Demo. The team means AI teammates, no online play for this one… yet. Technically, if you fly long enough you can arrive at the planets. The game will eventually feature some sort of landing, probably not seamless atmosphere flight as that is just magical to me.

screen_249.6802

There are also jump gates that are functional. Again they require flying far into space. They are glowing spheres. Hit one and you will jump to a new system. These will eventually link between systems in a way that makes sense. For now they are random… The main ‘game’ of this demo is just destroying the enemy fleet and then auto-jumping to the next round. It’s hard. Here is the link to the Webplayer (PC and Mac Coming soon)… Frame rate seems ok when I play it, but mileage may vary –should run real fast on the standalone build.

Tips:
On the web version – Right click and Go Fullscreen. This will allow the mouse to lock and give you the ability to use the right mouse button to do a barrel roll.

Here is a video of some gameplay:

Surprise – more work on Space Wars!

spacewarp

My September game of the month has been an exploration of procedural (kinda random) generation of star systems that players can travel to through jump points. I’ve been using Space for Unity Construction Kit which makes really pretty stuff even when I write code to completely randomize its elements. I haven’t done the math, but just to choose a random seed, if picks a random number between 1 and 5 million or something so there are at least 5 million variations of star systems I suppose. Some might be more interesting than others.

Here is a video:

Hope to have a demo online soon!

spacewarsfight

Zombies… New #1GAM game for July!

Zombies have invaded Badger Head Games! My game for July is complete! (As complete as a one month game can be, right?) It’s not perfect, but it has zombies and a semblance of a plot! Basically, you try to escape the zombies by contacting a rescue helicopter. You start with your bare hands, but can find a baseball bat and a pistol to fight off the zombie hordes. There are also helpful first aid kits!

zombiessplash_edited-1

Zombies use sight lines to see you, so you sneak around them. They react to noise so guns aren’t always super smart. (Or helicopters…)

Disclaimer: There is a little bit of cartoonish / blocky violence so get permission from parents before you play… (gun noises and puffs of blood here and there are about it oh and whacking zombies on the head)

Click here to play the web version – (I suspect this might not work the best on the web…)

Save as to get PC *.zip file

Save as to get Mac *.zip file

(above are updated with bug fix 7/31 at 8:24PM EST)

Problems- My house model went a little wonky when I combined the meshes so they are a little messed up-you might see some glitching there. Also I have working doors but ran out of time to put them all back in. I also wanted more weapons, crawling zombies, path finding…, different building models, more items, survival components, a longer game… Also, the game can be super easy or super impossible depending on how you play I guess. So in the next version…

New Space Wars Build – Missiles, Single Player Mode, Bigger Cooler Map #1GAM

Screen Shot 2014-06-19 at 6.59.45 PM

Ok so here it is, I’ve been posting video of this work in progress so now you can play it!  Here is the link to Space Wars Net. 

It’s not perfect – missiles don’t really work in multiplayer because of targeting. I have to rewrite the way I handle missiles to get that to work. They work fine against AI enemies tho.

The controls have changed a little – F or Right Mouse for Missiles. Space or Left Mouse for lasers.  Mouse Look to steer. Q-E to strafe.

Update: On further testing – I think I made the multiplayer cooperative… can’t seem to hurt the other player due to the collision detection. Didn’t want players to blow themselves up with their own missiles. I will fix this in the next update. Perhaps I need to add a teams dialogue to the log in screen.