- Home /
Problem is not reproducible or outdated
I wrote a good code for simple movement but it still lagging and flickering
HI I don't understand why simple movement need to lagging, even on powerful devices. The devices that I use: pc GeForce GTX 1050 Ti, iphone 12 pro, and vivo. It would be worse if I recorded it.
The codes are okay. But I don't know why lagging in a sudden and sprite flickering. Should the problem be in project setting ? This a simple movement code:
using UnityEngine;
public class chunk_controller : MonoBehaviour {
public float move_speed;
private Rigidbody2D rb;
private Vector2 dir;
private public bool disable_move;
void Start() {
get = this;
disable_move = false;
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate() {
move_position_movment();
delete_chunk();
}
private void move_position_movment() {
rb.MovePosition(rb.position + Vector2.down * move_speed * Time.deltaTime);
}
private void delete_chunk() {
if(
transform.position.y <= -20
) {
Destroy(this.gameObject);
}
}
private void edit_references() {
move_speed = 8;
}
}
[1]: https://forum.unity.com/attachments/ezgif-3-1cc29e5b0f-gif.1046210/?temp_hash=e7a57247f8c54d1c49be7c8cc25b2c7c
Project settings image: https://forum.unity.com/attachments...6/?temp_hash=e7a57247f8c54d1c49be7c8cc25b2c7c
Camera settings image: https://forum.unity.com/attachments...9/?temp_hash=e7a57247f8c54d1c49be7c8cc25b2c7c
Rigidbody2D settings image: https://forum.unity.com/attachments...2/?temp_hash=e7a57247f8c54d1c49be7c8cc25b2c7c
Answer by KloverGames · Apr 29 at 05:30 PM
Try Update() and compare it to FixedUpdate()
Check out this video! Explains the possible reasons for such problem https://www.youtube.com/watch?v=qtV8JEIq0Ng