- Home /
Fighting Game - Aiming attack animation at mouse cursor?
Hi guys, I'm planning out a fighting game. The game will be a 2d sidescroller combined with arcade fighting type controls but using the mouse to aim your attack. All characters/enemies will be 3D rigged/animated models. If I make an animation for swinging a scythe (example) horizontally, (for the purposes of clarity, if I say 'horizontal' I mean there is no vertical component to the attack, not that the swing happens on a flat horizontal plane) how can I make it so that horizontal swing is aimed at the mouse cursor? Of course I could aim some of his spine/chest joints gradually towards the mouse, but that will end up making weird poses. I could also have a vertical horizontal (swinging horizontally, but aiming straight up at 180degrees from the ground) swing, a diagonal horizontal, and a horizontal horizontal.
Hope that isn't too confusing. I want the swinging animations to aim at the cursor and would love if someone could provide a starting point. I know I'll have to raycast from the mouse position to the world but this is more about getting the animation to point at the location.
Cheers
Answer by whydoidoit · Jul 02, 2012 at 09:20 AM
Hmmm, not at all easy - you are asking for an Inverse Kinematic solution I think where the animation is retargetted at run time. Looks like that is coming in 4 Pro, but there arent any solutions I've found and I'm half way through writing one, but may give up due to version 4.
Your best bet might be to rotate the bone near the chest having worked out the relative angle between that one and the scythe at the moment of impact. Full IK means working back from the end effector (tip of the scythe) though all of the bones in the body adjusting them to look natural (and taking into account the limited degrees of freedom of each bone).