Hi Unity forums, having a little trouble wrestling with the unity script (JavaScript) in my game.
What I currently have is my character walking, running and jumping with keyboard commands on a 2d plane (x axis).
I want to be able to have a one key press disable these movements and assume the model into the crouch position.
While in this position the character will equip their gun, and all control will be shifted to the mouse movement (think defensive, rotating turret). When moving the mouse button, the top half of the character (lower torso upwards, including arms) will follow the mouse pointer on an axis at the waist. Essentially, aiming with the mouse on a 3d plane (x axis).
When the key command is pressed again, movement on the 2d plane (walking, running, ect) resumes, and mouse control is disabled.
I currently have the walking mechanics near enough done. I have also assign a material to the mouse (which follows the mouse where ever it goes) but what I’m struggling with is the aiming mechanics.
I have tried assigning this script to the lower torso bone, which is parents to the top half of the body (all the bones I want to move):
var target : Transform;
function Update () {
if (Input.GetButtonDown("Mouse2"))
transform.LookAt(target);
}
Simple, I know as it doesn’t even remotely work. What I would like to know is if anyone knows whether this game mechanic has been done before in unity, and how it was achieved? Or just general suggestions on how to perform this. I’m not a coder by profession, so I apologies for this topic in advance, I’d just really like to be able to learn how to perform this action.
Here is a link to a paint drawing I whipped up to add a visual description to what I’m trying to achieve here.
Thanks,
Terragot.