- Home /
Question by
herreratyler · Jan 26, 2015 at 04:37 AM ·
objectscriptingproblemmultiply
what's wrong with this script?
when active, it causes the player model's transform component to duplicate endlessly. here is the script:
#pragma strict
var anim : Animator;
//var jumpHash : int = Animator.StringToHash("Jump");
//var AnyStateHash : int = Animator.StringToHash("Base Layer.WalkFWD");
//var RunHash : int = Animator.StringToHash("Run");
var controllerheight : CharacterController;
function Start () {
anim = GetComponent("Animator");
controllerheight = GetComponent(CharacterController);
controllerheight.transform.position.y = 1;
//GameObject("vincent").GetComponent(Transform);
}
function Update () {
var move : float = Input.GetAxis ("Vertical");
anim.SetFloat("Speed", move);
var move2 : float = Input.GetAxis("Horizontal");
anim.SetFloat("Speed2", move2);
//var stateInfo : AnimatorStateInfo = anim.GetCurrentAnimatorStateInfo(0);
if (Input.GetKeyDown(KeyCode.Space)/* && stateInfo.nameHash == AnyStateHash*/){
anim.SetTrigger("Jump");
}
if (Input.GetKeyDown(KeyCode.LeftShift)){
anim.SetBool("sprintPress", true);
}
if(Input.GetKeyUp(KeyCode.LeftShift)) {
anim.SetBool("sprintPress", false);
}
if (Input.GetKeyDown(KeyCode.LeftControl)){
anim.SetBool("Crouch", true);
controllerheight.height = 1.03;
controllerheight.center.y = 0.51;
}
if (Input.GetKeyUp(KeyCode.LeftControl)){
anim.SetBool("Crouch", false);
controllerheight.height = 1.75;
controllerheight.center.y = 0.87;
}
if (Input.GetKeyDown(KeyCode.E)){
anim.SetTrigger("Roll");
controllerheight.height = 1.03;
controllerheight.center.y = 0.51;
}
else if (Input.GetKeyUp(KeyCode.E)){
controllerheight.height = 1.75;
controllerheight.center.y = 0.87;
}
if (GameObject("vincent").transform.position.y >= 4){
anim.SetBool("Falling", true);
}
else if (GameObject("vincent").transform.position.y == 4){
anim.SetBool("Falling", false);
}
//if (Input.GetKeyDown(KeyCode.LeftShift);
}
(EDIT: Turns out, I solved my problem before anyone answered. To the moderators, delete if you wish.)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613181533im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem with overlapping objects, same shader 0 Answers
'Pre-create object VS Create when needed' Performance difference 1 Answer
How to change use transform.LookAt to make the bottom of an object look at something? 0 Answers
Add objects on the surface of another object 1 Answer
Lighting and terrain 0 Answers