hi there
i’m making a 2d game , i have this canvas (in the picture) , the player runs and jump with the speed I want in the editor , but when I build it to the windows platform : the player runs and jumps very slowly (it’s not a problem in my graphic card , my friend also tried it and its the samething)
How can I fix it ?
thanks

UI is not intended for such purposes… however, if you want to use it anyways you will need to make sure that the proportions are correct. In other words: you probably want to control the anchored positions of your character rather than some positions which are affected by the canvas scaler.
PS: you should be able to reproduce it in unity by changing the resolution of the game window.
Show your code for player movement. Most likely you’re not correctly scaling the movement for different framerates.
1 Like
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float maxSpeed = 6f;
public float jumpForce = 980f;
public Transform groundCheck;
public LayerMask whatIsGround;
public float verticalSpeed = 4;
[HideInInspector]
public bool lookingRight = true;
bool doubleJump = false;
public GameObject Boost;
private Animator cloudanim;
public GameObject Cloud;
public GameObject gameoverground;
public Camera mycam;
private Rigidbody2D rb2d;
private Animator anim;
private bool isGrounded = false;
// Use this for initialization
void Start () {
rb2d = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
//cloudanim = GetComponent<Animator>();
Cloud = GameObject.Find("Cloud");
// rb2d.velocity *= mycam.orthographicSize * 1,
//cloudanim = GameObject.Find("Cloud(Clone)").GetComponent<Animator>();
}
void OnCollisionEnter2D(Collision2D collision2D) {
if (collision2D.relativeVelocity.magnitude > 20){
Boost = Instantiate(Resources.Load("Prefabs/Cloud"), transform.position, transform.rotation) as GameObject;
// cloudanim.Play("cloud");
}
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Jump") && (isGrounded || !doubleJump))
{
GetComponent<AudioSource> ().Play ();
rb2d.AddForce(new Vector2(0, 1080f));
rb2d.velocity *= mycam.orthographicSize * 0.11f;
if (!doubleJump && !isGrounded)
{
doubleJump = true;
Boost = Instantiate(Resources.Load("Prefabs/Cloud"), transform.position, transform.rotation) as GameObject;
// cloudanim.Play("cloud");
}
}
if (Input.GetButtonDown("Vertical") && !isGrounded)
{
rb2d.AddForce(new Vector2(0,-jumpForce));
Boost = Instantiate(Resources.Load("Prefabs/Cloud"), transform.position, transform.rotation) as GameObject;
//cloudanim.Play("cloud");
}
}
void FixedUpdate()
{
if (isGrounded)
doubleJump = false;
float hor = Input.GetAxis ("Horizontal");
anim.SetFloat ("Speed", Mathf.Abs (hor));
rb2d.velocity = new Vector2 (hor * maxSpeed, rb2d.velocity.y);
isGrounded = Physics2D.OverlapCircle (groundCheck.position, 0.15F, whatIsGround);
anim.SetBool ("IsGrounded", isGrounded);
if ((hor > 0 && !lookingRight)||(hor < 0 && lookingRight))
Flip ();
anim.SetFloat ("vSpeed", GetComponent<Rigidbody2D>().velocity.y);
}
public void Flip()
{
lookingRight = !lookingRight;
Vector3 myScale = transform.localScale;
myScale.x *= -1;
transform.localScale = myScale;
}
}