I found the following script on the forum and I’m wondering if there’s anyway to slow down the movement.
// the scary broken arm movements, probably:
var shoulder : Transform;
var shoulderControl = 0.9;
var elbow : Transform;
var elbowControl = 0.4;
var hand : Transform;
var handControl = 0.1;
private var currentDirection : Vector3 = Vector3.forward;
// animation is applied every frame in between Update() and LateUpdate().
// doing this in LateUpdate has the effect of blending between
// our procedural rotation for the arm bones and the pre existing one.
function LateUpdate ()
{
currentDirection.x = Mathf.Clamp(currentDirection.x + Input.GetAxis("Mouse X"), -1, 1);
currentDirection.y = Mathf.Clamp(currentDirection.y + Input.GetAxis("Mouse Y"), -1, 1);
var rotation : Quaternion = Quaternion.LookRotation(currentDirection);
shoulder.localRotation = Quaternion.Slerp(shoulder.localRotation, rotation, shoulderControl);
elbow.localRotation = Quaternion.Slerp(elbow.localRotation, rotation, elbowControl);
hand.localRotation = Quaternion.Slerp(hand.localRotation, rotation, handControl);
}
// but you can make it as complex as you like, as procedural animation often needs to be complicated
//end of code
Sure, just multiply the Input.GetAxis() calls by some scaling factor (i.e. by a number < 1.0) and/or change the bounds in the Mathf.Clamp() calls (depending on the effect you want to achieve).
There’s no movement in that code, but once you do find whatever’s moving you just multiply it by something less than 1.0.
Thanks guys, the speed works well. I used just the spine variables and it’s almost perfect.
The only problem now was getting the rotation to follow the mouse correctly. After switching the Mouse X and Y, vertical rotation worked well. Sideways was inverted.
I changed the multiplying variable of the sideways rotation to a negative value and it’s working well now. Not as perfect as the darned impossible to understand arm ik(hopefully someone will do a tutorial or a solution that works without too much tweaking… never got it to work with my models
) but after months of looking for a solution, my character can turn his spine quite well and can shoot in any location!!!
Thanks guys. Is there anyway to improve on it? I’ll try using the upper arm bones rather than the spine later. Might need few changes. Here’s the modified script:
code:
var Spine : Transform;
var SpineLimiter : float = 0.9;
var sensitivityX : float = -0.1;
var sensitivityY : float = 0.1;
var currentRotation : Vector3 = Vector3.forward;
function LateUpdate()
{
currentRotation.x = Mathf.Clamp(currentRotation.x - Input.GetAxis("Mouse Y") * sensitivityY, -1, 1);
currentRotation.y = Mathf.Clamp(currentRotation.y - Input.GetAxis("Mouse X") * sensitivityX, -1, 1);
var rotation : Quaternion = Quaternion.LookRotation(currentRotation);
Spine.localRotation = Quaternion.Slerp(Spine.localRotation, rotation, SpineLimiter);
}