- Home /
transform.position not setting position OR animation setting position even though it shouldn't
I am not sure which one of the things in my title is the problem. Here is the script:
private Animator anim;
public int line;
public int maxLine;
public float posAwayFromZero;
public bool dead;
void Start(){
anim = GetComponent<Animator>();
dead = false;
}
void Update(){
if(line >= maxLine){
line = 0;
}
else{
transform.position = new Vector2((0 - posAwayFromZero) + (line * posAwayFromZero), transform.position.y);
Debug.Log((0 - posAwayFromZero + line * posAwayFromZero).ToString() + transform.position.y.ToString());
}
if(Input.GetKeyDown("space") && !dead){
line++;
}
}
if you need clarification, line is set to 0, maxLine to 3, and posAwayFromZero to 3
the player does nothing, and when i Debug.Log the exact same thing it shows another position (the player is always at where ever it is when game is started, and when i look into the console (i have that debug.log there), it shows the position it should be at.)
My animator shouldn't move the player as the default animation only has the component to enable the fire under the rocket (the player) and is changed only when the player dies.
Your answer
Follow this Question
Related Questions
Why when creating new animator controller for the character the character is not walking right ? 0 Answers
How can i check if animation has finished playing if the object have no animator attached ? 1 Answer
Having an animation enabled locks transform changed in the animation 3 Answers
Animations out of sync? 0 Answers
Animator is not playing a Playable 3 Answers