- Home /
using ironsights wont work standing still
So i have my gun made the animation for zooming in and everything but the character only zooms if im walking i want him to be able to stand still and use iron sights but it wont work help!
var PlayerState : int = 0; var PlayerAnimSec : GameObject;
var PlayerMotor : CharacterMotor;
var WalkingSpeed : float = 6;
var SprintingSpeed : float =8;
var PlayerBossController : CharacterController;
var CharacterVelocity;
var CharacterMag;
var PlayerAimingInSpeed : float = 0.2;
function Start () {
}
function Update () {
PlayerAnims();
PlayerStateController();
CharacterMag = PlayerBossController.velocity.magnitude;
}
function PlayerStateController () { if(Input.GetAxis("Vertical") || Input.GetAxis("Horizontal")) {
if(Input.GetButton ("Sprint")&&!Input.GetMouseButton(1)) {
PlayerState = 2;
}
else if (Input.GetMouseButton(1)&& !Input.GetButton ("Sprint")) {
PlayerState = 3;
}
else {
PlayerState = 1;
}
}
else {
PlayerState = 0;
}
}
function PlayerAnims () {
if(PlayerState == 0) {
PlayerAnimSec.animation.CrossFade("idle_animation", 0.4);
}
else if (PlayerState == 1) {
PlayerAnimSec.animation.CrossFade("walking_animation", 0.4);
PlayerAnimSec.animation["walking_animation"].speed = CharacterMag/WalkingSpeed;
PlayerMotor.movement.maxForwardSpeed = WalkingSpeed ;
PlayerMotor.movement.maxBackwardsSpeed = WalkingSpeed/2;
PlayerMotor.movement.maxSidewaysSpeed = WalkingSpeed ;
}
else if (PlayerState == 2) {
PlayerAnimSec.animation["sprint_animation"].speed = CharacterMag/SprintingSpeed;
PlayerAnimSec.animation.CrossFade("sprint_animation",PlayerAimingInSpeed);
PlayerMotor.movement.maxForwardSpeed = SprintingSpeed ;
PlayerMotor.movement.maxBackwardsSpeed = SprintingSpeed/2;
PlayerMotor.movement.maxSidewaysSpeed = SprintingSpeed ;
}
else if (PlayerState == 3) {
PlayerAnimSec.animation["aiming_idle"].speed = CharacterMag/SprintingSpeed;
PlayerAnimSec.animation.CrossFade("aiming_idle",PlayerAimingInSpeed);
PlayerMotor.movement.maxForwardSpeed = SprintingSpeed/0.8 ;
PlayerMotor.movement.maxBackwardsSpeed = SprintingSpeed/0.3;
PlayerMotor.movement.maxSidewaysSpeed = SprintingSpeed/0.8 ;
}
}
Help please!!!
Comment
Your answer
Follow this Question
Related Questions
I need help with Javascript 2 Answers
How to add sound to gun shot script 4 Answers
Who has good FPS hands / arms ? 0 Answers
How to add gun to the model, as when it animate, the gun is dis-positioned. 2 Answers
Problem with camera 1 Answer