Rocket Fist is a multiplayer arena game with armless robots in chaotic battles with rocket fists. Prove your dexterity and aim against your frenemies killing each other with rocket propelled fists in this frenetic mix of dodgeball and billiards!

Post news Report RSS Player AI Improvements

In today's devlog I talk about how I created a more challenging player AI by making it aware of it's surroundings.

Posted by on

[​IMG]


Today was a pretty productive day, I did several small tasks and one big task.

[​IMG]


Small changes:

  • Improved player speed yet again, originally at version 0.03 it was 3.2f, then on version 0.04 it was 4f, now it’s 4.3f, I don’t know how I lived so long with the slow speed of 3.2f D:
  • The pause menu was without animations, since I used Time.Timescale = 0 to pause and the animations were using delta time, they were not working, that’s now fixed :) those animations are now using Time.realtimesincestartup and are imune to Timescale.
  • Player’s 3 letter name are now used in the game, they show up when players spawn for a couple of seconds then hide. They can appear again if a player presses Select on the controller. That’s useful to find yourself if you’re confused. I’m also going to add the player’s name to the scoreboard on the top, but I haven’t yet.
  • I did color correction on the menu scene, don’t know how I forgot to do that before D: looks much better now.
  • Talking about color, I made the colors on the player textures a bit darker, you can probably see by the picture on the top here, much better <3
  • Made the default on the player menu to be having 1 bot active, since most people seem to be playing by themselves with bots lately.
  • Made the controller vibrate whenever you die, stun someone, get stunned or counter :D It’s so cool! and was pretty easy to implement.
  • Buffed medium AI a little bit, now he will use a raycast in front of him with bounces to determine if he should shoot or not. He still has a 15% of chance per frame that he has line of sight with other player to shoot though, but the chance will only get above 50% if he knows it can hit you via raycast. I might need to add an AI between easy and medium that won’t raycast you but will try to shoot in your general direction like previous medium AI used to.

Now for the big change, the Hard AI. For the Hard AI I wanted it to use raycasts to figure out if it had a good shot accounting for bounces. I started writing this code back in the end of february, as I thought of making this little challenge mode game for rocket fist and for level design purposes I made a laser pointer that showed me the bounces the weapon would do.

[​IMG]


That way I woul easily be able to see if the level was solvable as I created levels, and would be able to move things around to make sure the bounces would make for possible levels.

So, I got that piece of code back and implemented it into my player. I thought of having a temporary laser aim powerup whenever I get around implementing the power up system, so I seized the opportunity and made myself a little laser aim using LineRenderers.

[​IMG]

Doing that for the current weapon position is pretty easy, but to check for possible bounces I should check all around the player. I could just raycast to different directions from the center of the player, but that’s not where the weapons are shot from… So I had a problem: I would have to find where my weapon would be for my player’s rotations.

[​IMG]

My solution is probably not the most elegant, but it works, I created a new empty game object and made it follow the center of my player. Every frame when I’m doing my raycasts, I run a for loop in which I:
  • Get the distance between the weapon and the player, get the position of the player and add the transform.right of this empty game object multiplied by that distance, that’s the position of the weapon for that rotation.
  • I then do my raycasting (with bounces) from that position in the direction of the transform.forward of my empty game Object.
  • I save in arrays the position, direction of the ray and if I found a player his transform.
  • Afterwards, I rotate this emptyGameObject 45 degrees.
  • Whenever I finish my for loop I return it to 0 degrees.

That gives me rays all around my player from the position the weapon would be, and since the empty game object is following the player but is not a child of it, it won’t keep rotating and changing directions, the direction I get from there I can use to rotate my players towards.

[​IMG]


Here is another picture of it, this time with bounces turned on. I made it so whenever a ray found a player it colored the line blue, so it would be easier to know if it was working.

[​IMG]


I made a copy of the Herp AI (Medium Difficulty) and messed around with the section in which it tryes to shoot at the player. Now it will keep checking on it’s web of raycasts if it has any possible shot to the player accounting for bounces all around. If it does, it will tilt the analog stick in that direction. Whenever the main raycast (that one changes with the player and is always pointing forward) finds a player, it will have a 55% of chance per frame of pressing A, otherwise it’s 10% chance if it’s in the same vincinity of the player and looking vaguely in the player’s direction.

This has made the AI extremely evil, it gets me with crazy shots I wasn’t expecting. To make things worse I added a new method for finding weapons, so if this AI doesnt’have a weapon but the closest player does, it will look for a farthest weapon from the closest player, so it doesn’t get baited to a weapon that I’m guarding instead of going for another unguarded one.

I played 1vs1 against it 3 full matches and I still haven’t managed to beat it in a full match (I kill it sometimes of course, but it’s winning the full matches against me ><). In my defense, it’s late and I’m tired!

[​IMG]


You can see the evil AI destroying me in the GIF above (I’m naming it Troll… now I have Derp, Herp and Troll).

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Rocket Fist
Platforms
Windows, Mac, XONE, WiiU
Creator
DanielSndDev
Engine
Unity
Contact
Send Message
Release date
Game watch
Follow
News
Tags
Dev Diary
Browse
News
New
Post news
Report
Report
Share
Related Games
Rocket Fist
Rocket Fist Arcade
Related Engines
Unity
Unity Commercial