Weird flickering on moving 2d objects
Asked Answered
S

3

0

I’m making a 2d endless runner where the players has to move the character left and right and white obstacles are moving from the top to the bottom (the “pipes” are moving down, not the player up!)

But the moving obstacles flicker a bit when playing the game in the GAME-tab in unity and they flicker a lot when playing the game on my mobile device. The obstacles are moved downwards with;

rb.velocity = new Vector2(0, BarrierSpawner.speedY);

Here’s a video of the gameplay on my phone:

Sheppard answered 25/8, 2023 at 12:19 Comment(0)
V
0

There are two primary reasons this could happen:

  • You’re setting velocity in Update. If you do that, you’re messing with the Physics Engine. Do this in FixedUpdate.

  • The rather less likely case is you’re moving the game camera which you should do in Update.

Vendible answered 25/8, 2023 at 12:16 Comment(2)

@Vendible Thanks for your reply. All movement-related code is in FixedUpdate and I do not move the camera. Any other ideas why this could happen?

Sheppard

are sure its unity and not reality malfunctioning???

Unbonnet
G
0

Yo, I bet you have moved on… By some miracle if u still need this (u dont) just make the player 1 layer ahead of the background.

Gastro answered 6/6, 2023 at 2:41 Comment(0)
T
0

Hi, I know this is and old topic but I’m facing the same problem and don’t know what else I can do to avoid that effect. Do you have a solution?

Tractate answered 24/8, 2023 at 12:41 Comment(1)

Since this is not a resolved issue I suggest creating a new thread and providing as much details about your specific case as you can there.

Metcalfe

© 2022 - 2024 — McMap. All rights reserved.