- Home /
Question by
Marsallima · Jan 24, 2012 at 11:02 PM ·
transformvector3fpsquaternionweapon
Avart Fate with Gun Movement
Hey Guys, i am trying to "inverse" the rotation in this script:
#pragma strict
var speed: float = 15; // speed to follow camera
private var localRot: Quaternion;
private var curRot: Quaternion;
function Awake(){
localRot = transform.localRotation; // save initial local rotation
curRot = transform.rotation;
}
function LateUpdate(){
// targetRot follows instantly the camera:
var targetRot = transform.parent.rotation * localRot;
// curRot follows targetRot with some smoothing delay:
curRot = Quaternion.Lerp(curRot, targetRot, speed * Time.deltaTime);
transform.rotation = curRot; // update the actual weapon rotation
}
Why, i am trying to put in a Weapon, and the effect is not the way it would be ( Sorry for my bad english xD )
If you not undstand try to put this script in a weapon and you go undstand. Thanks :D
Comment