Morning!
I’m creating a game in 3D/2D I mean somthing like Smash Bros, Kirby64 and that kind.
Well, I have a few weeks, so I can not model and animate a character and I’m using the third person prototype from Unity but changing textures and adding armor on him.
My problem is when I try to make his arm follow the mouse because it is preanimated and the interaction cross with the animation, so I want to ask you people if there is some way to take off the arm from the animation or something that let me guide the arm with the mouse.
I’m using this code.
#pragma strict
var mouse_pos : Vector3;
var target : Transform; //Assign to the object you want to rotate
var object_pos : Vector3;
var angle : float;
function Update ()
{
mouse_pos = Input.mousePosition;
mouse_pos.z = 15; //The distance between the camera and object
object_pos = Camera.main.WorldToScreenPoint(target.position);
mouse_pos.x = mouse_pos.x - object_pos.x;
mouse_pos.y = mouse_pos.y - object_pos.y;
angle = Mathf.Atan2(mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(Vector3(0, 0, angle));
}
And i know that works cuz all the character rolls in a crazy weird dancing and its cuz the interaction cross with the animation. Well I think thats the reason.
Thnx! I hope you can help me, have a nice day (: