0

I have a mobile game in which there are invisible walls with a collider at the edge of the screens such that the game objects inside it can only be in the screen area and not outside of it. However, when I see my reviews it seems that the objects inside sometimes go outside of these walls because when you tap they may suddenly start moving fast and thus they may one frame be inside the walls and the next frame outside of them. (Mostly on slower devices)

The question is now: how should I handle this problem. Should I maybe make the movement slower or implement a function that checks whether it is still in the walls (seems not so elegant) or something else?

6
  • What kind of collider are you using for the walls? Also, is this a 2d or 3d game? Commented Oct 8, 2019 at 20:24
  • @Ruzihm it's a 3d game and the walls have a box collider. The're actually just boxes without a renderer and scaled out to be long Commented Oct 8, 2019 at 20:50
  • The simplest step to try first would be to just make the boxes larger so that they extend further to the the outside of the world. Does that solve your issue? Commented Oct 8, 2019 at 20:56
  • Have you set the collision detection type to continuous on the RigidBody2Ds? Commented Oct 9, 2019 at 7:24
  • are you moving the transform (=breaks physics) or rigidbody? Commented Oct 9, 2019 at 9:34

2 Answers 2

3

On your moving objects Rigidbody component, change the Collision Detection type from 'Discrete' to 'Continuous Dynamic'.

Sign up to request clarification or add additional context in comments.

Comments

0

PS: I can't comment yet so I'll put mine here.

  • You can always have a dual barrier ( not an elegant solution but will work ).
  • Optimize more your game so that even at the lowest specification your game is playable and not only that, this might help your collider detects faster if the game is not laggy right?
  • If it hits the wall you can set a restart point maybe?

Just a suggestion that might help I guess. Good day mate :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.