1
$\begingroup$

Often times in video games that use melee combat, there are three or four preset animations that play through when you swing your weapon; however, the higher end games have different strokes that play depending on which way you are moving your mouse or have recently moved your mouse, effectively giving you the ability to control where you attack, and requiring more skill.

How would I implement this in the Blender Game Engine? I want to play a different animation or attack based on which direction my mouse has just moved.

$\endgroup$
1
  • 1
    $\begingroup$ Two discoveries, clicking "answer your own question" will not post the question, and you can't "answer your onw question" twice, you must post, then write the second one. $\endgroup$
    – ruckus
    May 12, 2015 at 22:23

2 Answers 2

1
$\begingroup$

Another way to do this creates more variation of animation, but grants the player less control. (Maybe a good thing?) This is another no python approach.

You will need the empty from the other answer, but aside from that, it's a whole new experience.

The basic idea is to have 9 planes, all representing a different areas of the screen. by creating an action for each direction of swing, based on which plane is moused over, you give the player the ability to attack to the nine different portions, respectively, including a thrust, upward swings, and all normal downward chops.

enter image description here

After creating the planes and putting them in position in front of the camera, you will need to parent them to the floating empty, who's lag will mean that shortly after the mouse moves, there will be time to mouse_over and mouse_click the invisible, sensor physic type planes. By parenting them all to the empty, rather than all to the player, we avoid potential overlapping: i.e. they will stay the same in relation to each other.

After creating all the animations* (thrust for the center) we can give each plane it's necessary logic-sending a message with it's ID number to the armature so it knows which animations to play.

the combination of several animations per screen area and a random sensor can make for very interesting combat. :)

$\endgroup$
1
$\begingroup$

After trying to solve this problem by myself for almost my entire blender career, I stumbled across a solution. This is a no python approach.

The basic idea is to have an empty, offset from the player, and "slow parented" to the player that two specialized bones track toward. By animating a normal downward chopping motion, as well as the influence value of the track-to bone constraint, we can cause the player to chop across in his upper arc. This comes at the expense of variation as the player can't chop up from a downward position or thrust.

Step 1

For you basic setup, you will need to create three extra bones: one for each shoulder, and one that control those two so they don't point inward. You will also need to create a "plain axis" empty that the control bone tracks to. Add a track to bone constraint on the control bone and set it's target as the empty, which will need a slight upward and forward offset (see figure 1). Parent it to the player and give it some slow parent value.

enter image description here

figure 1

enter image description here

Step 2

Animate your chopping motion; it should provide all the functionality you'll need. note: do not animate the shoulder bones as this might interfere with the essential tracking. Also animate the influence of the track-to constraint, starting at 1, staying at 1 until shortly before the end, and then moving to 0.

enter image description here

Step 3

Switch to the logic editor and add a mouse-click sensor, an AND controller, and a Action actuator, set to play mode and with the chopping/turning of the shoulders action.

[figure 3]()

Viola! looks a bit awkward, but hey, that's the cost of beheading people.

(edit) you will also need a run-armature actuator

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .