Aim and Shoot

New & Improved Aim

To be honest, the last aiming system I made was bad. It didn’t work very well and felt choppy to use. I wanted to create one that actually felt smooth and responsive.

I’ve instead moved to a pull approach, closer to the Angry Birds one I talked about last week works. This is done by hiding the players mouse and clamping it to a circular area around the player. This means that if the player walks back and forth, the mouse will follow them. I think this is the best way to emulate how it would work on a joystick (which I unfortunately won’t have time to actually implement).

Using a little help from this tutorial by sashbros I also created a trajectory made of little dots to help aim the throw. It’s all my own code, I just needed a little help on how to calculate the trajectory of where the physics would take the spear.

Enough talking, here’s a little demo of what it looks like to aim:

Where’s the Shooting?

Well, in order to implement the spear actually being thrown, I first had to create a system where the spear would rotate to the trajectory of the throw. Unfortunately, without complex physics and air resistence, spears don’t just align themselves to a throw as they do in real life. Essentially all I’m doing is setting the spears rotation perpendicular to its previous motion vector.

Here’s an example of it working:

I am aware that currently the spear is not pixel perfect, I plan to address that next week!

By

Posted in