0
I created a game like Infinite Runner that works properly in the Unity 5 Game tab but in android when I perform Jump in my character it has a climb always of different size, how can I solve this problem?
OBS: The app was tested on 2 different Androids (4.4.2 and 5.0) (had the error in question).
Functions that perform Jump
void FixedUpdate () {
CheckPlayerInGround();
MakeJump();
animator.SetBool("jump", !steppingDown);
}
void CheckPlayerInGround(){
steppingDown = Physics2D.OverlapCircle(GroundCheck.position, 0.2f, whatIsGround);
}
void MakeJump(){
if(Input.touchCount > 0){
if((Input.GetTouch(0).position.x < Screen.width / 2) && steppingDown){
if(slide == true){
UpdateColliderScenarioPosition(0.37f);
slide = false;
}
audio.PlayOneShot(audioJump);
audio.volume = 0.75f;
playerRigidbody2D.AddForce(new Vector2(0, jumpPower * Time.fixedDeltaTime));
}
}
}
I did a search and from what I saw may be related to the framerate tries to take a look
– Gabriel Augusto
Where is defined
jumpPower? Does its value change somewhere? And the functionUpdateColliderScenarioPosition, what does it do? Why does it receive a fixed parameter with the value 0.37? Without these details, it is difficult to know where there can be an error.– Luiz Vieira
Anyway, you’re mixing physics with frame rate management. Unity already does this for you when you use physics. Try to get the
* Time.fixedDeltaTimemultiplication by the force of the leap.– Luiz Vieira
@Luizvieira jumpPower is defined by the inspector (2500f), it does not change during the game, Updatecolliderscenarioposition so that the collider jumps and does not crash with the barriers of the set.
– Ricardo
@Luizvieira without the
* Time.fixedDeltaTimethe character goes off the screen, to solve I downloaded thejumpPowerto 250 ma continuously exiting the screen (in the Unity editor tab jumps at the appropriate height with 250 in jumpPower)– Ricardo
@Luizvieira to stay with a suitable height on Android (4.4.2 and 5.0) changed the
jumpPowerto 50 however there is still an inconsistency of high heels– Ricardo
I got it. Well, you did put one
Debug.Logbefore the line that adds force? Perhaps in the real device it is being called many times in a row, adding more force than the intended?– Luiz Vieira
Do the elements appear in the same place on the device and in the editor? Is it just the jump that is in trouble? The problem must be related to the resolution, giving the feeling that the jump is higher or lower. What resolution is set in the editor (At the top of the game tab, there is a select with several options) and what is the device resolution?
– Filipe Moraes