Mousetracking/sideshooter

Hello, i will be making a basic sideshooter game, except i have one problem, i need the characters arm to follow wherever my mouse goes. Does anyone know of a script and/or a way to make the players arm and gun aim wherever my mouse is?
Anyhelp would be great,
Thanks
-coonerboy

Its probably possible to have 1 action that moves the location of the hand vertically and another that moves it horizontally, you can run both actions at once and control each with a properly to set the X/Y location.
Aftrer you get this working you can use IK to make the arm follow the hand.

Edit, ack don’t think this is possible because actions are mixed per channel (bone) not per axis. it might work with ipos though…

You could just have 1 action that has loads of locations stored in it and pick the closest one… thats horrible but it would work. you have 300,000 possible frames to work with :slight_smile:

Ok, this would be my last resort, but thanks for the idea. I was hoping that someone would have a script (seeing as i suck with python) that tracks where the mouse is, or is there another way to get an object to aim at the mouse pointer?
Thanks

You could use mouseFocusSensor, getHitPosition() as your doing a sideshooter it wouldn’t be too hard to put a plane in for the mouse ray to hit then use an empty and set its Z position to height, x and y appropriately with python.

As for aiming the gun/arm, this is something I have been rangling with. An ipo or action is probably the way to go, something along the lines of “if mouseTarget above character height play action look upwards”, or down as applicable. Although this aiming wont be perfrect if you single vertex parent an empty to the front of your gun with and always track to the mouse target empty your aim should be true. It should avoid a lot of python while your at it.

Hope that helps

Similar situation; I acheived this with parenting. The only difference was I split my character at the torso and had the torso track the mouse. The torso was parented to the character. My biggest issue was making sure the torso didn’t bend over backwards, so I added a ray sensor to point backwards with a 150 degree spread so that when the mouse went “behind” the character, It played an IPO which turned the charater around. You can do something similar with your character; separate the arm from the rest of the character. In my case, because of custom actions I also had to duplicate the armature. A little messy, but it works. Recently I posted a couple blends that show how to track the mouse with a python module. I’ll see if I can find it…Have a nice day,
-Brian