Trajectory Aiming

After watching Goran´s video about Trajectory Arcs: https://www.youtube.com/watch?v=ZRFNlJFrpEI , I decided to make a script where the gun or cannon automatically aims at the the target (which uses a mouseRay script) taking into account gravity. It doesn’t take into account air resistence or such. It draws an arc (as in the tutorial), and then if the collision point isn’t where the target is, it uses some simple algorithms to elevate or depress the gun.

The gun has a Min and Max rotation limit (found in the gun.py script as UpLimit and DownLimit).

It still needs some work though…

Here are some screenshots and a demo file:

Attachments

trajectoryAiming.blend (621 KB)



1 Like

You forgot to pack textures, but the rest work fine :slight_smile:

I don’t think there are any textures in the file. Which ones are you talking about?

Verry nice, i was just looking at tutorials, an example file to tear apart is great, thanks.

ps. indeed you misses a texture, the smoke omg, purple plane as smoke now haha, but that doesn’t matter.

Oh, the smoke! I completely forgot! Oh well, I just added it because I was bored, it’s not really neccessary.

THIS THING IS AWESOME!
You should definitely make a video tut on this! (like replacing the trajectory line with a palne or such)
Then we can make Mortars, Pirate ship battles (like in Assassin’s Creed Black Flag) in BGE! :smiley:

What do you mean “with a plane or such”?

By the way, it uses simple methods to calculate the trajectory, not a complicated formula, so if you’re not bad at maths you’ll probably understand it. :smiley:

I mean it’s not a line but a curved plane as the trajectory that can be shown? :confused: so we can texture the plane that’ll be added and make things look cool
ok

Like dots along the trajectory, like in Angry Birds? Or anything like that? I think you might be able to do something like spawn an object along each ot the points on the line. I’m not that good at python and the trajectory and drawing of the arc is quite complicated to me.

EDIT: Yep, you can! I just managed it. It spawns your object at every point of your arc. The lower the arc resoulution, the less objects spawned, and the same goes for higher resolution, more objects. Note that these objects keep going until the arc stops, so you might need to change arc timescale. Here’s a blend (I’ve disabled the line, and you might need to change the face orientation in the materials to billboard or halo):

Attachments

trajectoryAiming.blend (810 KB)