Find the news on strike hartsls or dharmas and list out news updates for 2 days ongoing movement in india
Answers
Answered by
0
Been doing a lot of reading and I have somewhat of an idea but not 100% sure about the proper way to handle a GameObject's movement along with its Animations. In this case it is my player movement scripts.
So what I was wondering is should I be placing the logic of my "movement" variable in my Update or FixedUpdate and should I also change anything up with my animation placement being in Update or put it in FixedUpdate? I have tried both and I see similar results, but I just want to have good practice for when bigger projects come along.
void Update(){
// IF we are allowed to move.
if(_PMS.canMove){
// Get a -1, 0 or 1.
moveHorizontal = Input.GetAxisRaw ("Horizontal");
moveVertical = Input.GetAxisRaw ("Vertical");
// Get Vector2 direction.
movement = new Vector2(moveHorizontal * _PMS.invertXDirection, moveVertical * _PMS.invertYDirection);
// Apply direction with speed.
movement *= speed;
// IF the user has an animation set.
if(anim != null){
// Play animations.
Helper_Manager.PlayerAnimation(moveHorizontal, moveVertical, anim, _PMS);
}
}
}
void FixedUpdate(){
// IF we are allowed to move.
if(_PMS.canMove){
// Apply the force for movement.
rb.AddForce(movement);
}
}
c# unity3d
shareimprove this question
edited Sep 3 '15 at 14:23
user3071284
3,76762643
asked Sep 2 '15 at 22:51
JoeyL
65321632
add a comment
1 Answer
active
So what I was wondering is should I be placing the logic of my "movement" variable in my Update or FixedUpdate and should I also change anything up with my animation placement being in Update or put it in FixedUpdate? I have tried both and I see similar results, but I just want to have good practice for when bigger projects come along.
void Update(){
// IF we are allowed to move.
if(_PMS.canMove){
// Get a -1, 0 or 1.
moveHorizontal = Input.GetAxisRaw ("Horizontal");
moveVertical = Input.GetAxisRaw ("Vertical");
// Get Vector2 direction.
movement = new Vector2(moveHorizontal * _PMS.invertXDirection, moveVertical * _PMS.invertYDirection);
// Apply direction with speed.
movement *= speed;
// IF the user has an animation set.
if(anim != null){
// Play animations.
Helper_Manager.PlayerAnimation(moveHorizontal, moveVertical, anim, _PMS);
}
}
}
void FixedUpdate(){
// IF we are allowed to move.
if(_PMS.canMove){
// Apply the force for movement.
rb.AddForce(movement);
}
}
c# unity3d
shareimprove this question
edited Sep 3 '15 at 14:23
user3071284
3,76762643
asked Sep 2 '15 at 22:51
JoeyL
65321632
add a comment
1 Answer
active
Similar questions