Advertisement Jump to content
eyal wahabi

R&D Moving an arm with a mouse

Recommended Posts

Am a new game dev and I need the help of you (the experts)

While making the game I had one main problem,

In my game, the player moves his mouse to control the direction of a sword that his character is supposed swings against other players,

the problem is that I don't know how to program the hand to move according to the mouse. 

I will be grateful if someone can give me a helping hand on how to code it or a general idea of how this thing can be programmed on unity ^^.

Share this post

Link to post
Share on other sites

Basically you' could start in a way similar to how a FPS camera works.

So, in the local space of the player, rotate around the up vector by horizontal mouse movement and around the side vector by vertical mouse movement.

However, this controls just the direction at which the straight sword points from the shoulder. There is no easy way to handle more detailed movements coming additionally from the wrist to control orientation of the sword from that point, because a mouse has only two axis. You would need something like a VR controller.

Or you work out a system that behaves natural and as intended most of the time. For this you need solid experience in solving geometric problems involving 3D rotations, a simple IK solver, some physics. You could look at a video of Kingdom Come Deliverance, and if you have no idea of how they might do this, then you won't get results good enough for a realistic game i guess. I'll end up being more kind of fun (like Fruit Ninja).

Share this post

Link to post
Share on other sites

That's a pretty open-ended question. Also probably not related to AI - I'm moving you to the Gameplay Programing forum.

First off, is this a 3D game with a first-person perspective? If the mouse is controlling the character's sword, then how does the player control where they are looking?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!