x


Making a character point his gun at the mouse

I'm working on a side-view game (like Bionic Commando Rearmed or Trine, for example).

I have a fully rigged character with animations working etc..., a crosshair script that gives the position of the mouse on the screen (as a 2D plane), and a gun model

What I'm trying to do is to put a gun in my character's hands (it could be different guns, not just one) and make him aim at wherever the mouse is pointing.

Basically, the mouse pointing is working fine, but I have no idea how to get the guy to hold the gun and move his whole upper body and arms to aim at the desired location while he is walking or standing still.

more ▼

asked May 04 '10 at 02:56 AM

Phil gravatar image

Phil
187 12 13 17

(comments are locked)
10|3000 characters needed characters left

2 answers: sort newest
more ▼

answered May 04 '10 at 04:45 PM

Tetrad gravatar image

Tetrad
7.2k 27 37 89

(comments are locked)
10|3000 characters needed characters left

First, you will need to create a Behaviour with handles to the Transforms of the shoulder, elbow, and wrist. You can manipulate these joints in the LateUpdate() event, which is invoked after animations have been applied.

The exact positions/rotations you need to compute for these joints are dependent on the constraints of your rig. There are several open-source Inverse Kinematics libraries you can reference for strategies, or you might get away with some simple heuristics based on the Law of Cosines. However, there's no one-size-fits-all solution.

more ▼

answered May 04 '10 at 02:26 PM

Max Kaufmann gravatar image

Max Kaufmann
573 10 12 21

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3767
x981

asked: May 04 '10 at 02:56 AM

Seen: 2533 times

Last Updated: May 04 '10 at 02:56 AM