Projectile: initial velocity angle to hit coordinate.

Categories code, physic

While working on an aiming system for one of my games, I faced this problem: “What should be the initial velocity angle for a projectile to hit given coordinate?” I wanted the bullet to pass thru mouse position. This image illustrates the problem:

Projectile angle to hit coordinate

The projectile should hit coordinate marked with red cross. The launcher has fixed power and bullets have fixed mass, so in my scenario the initial velocity vector length will be constant (I will adjust it accordingly to get nice gameplay). The intuition says that I’ll end up with more than one trajectory. One will hit the coordinate after reaching maximum height and another will use the shortest parabolic path. Continue reading “Projectile: initial velocity angle to hit coordinate.”

Potential Fields AI, 3/3: real game example.

Categories ai, code

Today I’ll write about my pretty advanced implementation of Pontential Fields AS3 library in upcoming game. This is the last part of Potential Fields AI article. It started with theory and basics in part 1. In part 2 you learned more about PFLib details and we implement RTS fighting bots demo. However, In near future I plan to port the library to few other languages and keep the update status on this blog.

Potential Fields real game example

Units in my game have their own attack behaviors. Zeppelins throw bombs at the target and drones attack with machine gun from right or left. Bots avoid collisions while being idle. They fly with different speed and acceleration and have various shot distances. It’s all running with my Pontential Fields AS3 library and Nape physic. Let me write about details! Continue reading “Potential Fields AI, 3/3: real game example.”

Potential Fields AI, 2/3: RTS bot implementation.

Categories ai, code

This is part 2 of Potential Fields AI article. In part 1 I presented you basic example of my Potential Fields AS3 library. Today we’re going to implement a game with RTS bots fighting against enemies. In part 3 I’ll describe AI details from my upcoming game.

RTS bots fighting.

Above image presents what we’re going to implement: two teams of bots fighting each other with guns. Each bot shots bullets of its own color. Continue reading “Potential Fields AI, 2/3: RTS bot implementation.”

Potential Fields AI, 1/3: hello potentials.

Categories ai, code

Potential fields are an interesting concept in games development. I decided to use them in my upcoming title, so I created a Potential Fields AS3 library (PFLib). This library drives bots AI in my RTS engine. The game is still in development, but here’s a video showing my current results (this gonna be pretty complex defense game with bots attacking your base and fighting against your team):

In this 3-part article I’ll tell you what are potential fields and how you can use my library to create AI in your games. In this first part I’ll start with some theory and basic AI implementation. Continue reading “Potential Fields AI, 1/3: hello potentials.”

Adobe AIR: “Error #1056: Cannot create property preventBackup on flash.filesystem.File.” error fix.

Categories Adobe AIR, code, iOS

Yay. I’m using Adobe AIR 3.7 merged into Flex SDK 4.6 and this error was raising on desktop and mobile at runtime. I forgot to define proper swf-version flag in my compiler settings. Here’s quick fix for FlashBuilder:

How to fix "Error #1056: Cannot create property preventBackup on flash.filesystem.File." error.

This took me about an hour, so I hope to save someone’s time.

PS. Here’s nice list of swf-versions values for different SDK configurations: -swf-versions list.