- Home /
Hot to use walking animation while aiming!
Hi, I currently want to use a walking animation while aiming, I use a script for aiming (not done by me) which translates the weapon to the aiming position when right click is held, but I cant seem to get both working together. any help. This is the code.
var applymode : boolean;
var ObjectToMove: GameObject;
var smoothTime : float = 1.0f;
var PositionX : float;
var PositionY : float;
var PositionZ : float;
var StartPos: Vector3;
function Start(){
StartPos = transform.localPosition;
}
function Apply()
{
var targetPosition : Vector3 = Vector3.Lerp(ObjectToMove.transform.localPosition, Vector3(PositionX,PositionY, PositionZ), Time.deltaTime * smoothTime);
ObjectToMove.transform.localPosition = targetPosition;
}
function ApplyOff()
{
applymode = false;
var targetPositionRes : Vector3 = Vector3.Lerp(ObjectToMove.transform.localPosition, StartPos, Time.deltaTime * smoothTime);
ObjectToMove.transform.localPosition = targetPositionRes;
}
function Update () {
if(Input.GetMouseButtonDown(1) && applymode == false){
applymode = true;
Apply();
}
if(Input.GetMouseButtonUp(1)){
applymode = false;
}
if(!applymode){
ApplyOff();
}
if(applymode){
Apply();
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Weapon Animation Help 0 Answers
problem with weapon animation -.- 0 Answers
Weapon Switch Animations 1 Answer
Weapon Shake 2 Answers