Reputation: 341
I am trying to make a flappy bird-type game for mobile but in 3D. As you can see in the picture, the object glitches through the ground. I have tried changing the collision mode from discrete to continuous dynamic but it didn't work.
Player Rigidbody settings:
For player to jump:
rigidBody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
To move ground:
transform.Translate(Vector3.left * GameManager.Instance.platformSpeed * Time.deltaTime);
It's worth mentioning that I have upgraded from 2021 LTS, the issue was also present in that version. The issue is also available even if the ground is not moving.
Upvotes: 1
Views: 51
Reputation: 447
When dealing with physics, don't use Transforms to move things around, instead use rigidbody.MovePosition(..)
and rigidbody.MoveRotation(..)
, otherwise the engine would not be able to correctly calculate the frame. If you have moving platforms in your game, add rigidbodies to them and use the same approach. Never move 'static' colliders dynamically (tat ones that are supposed to be your walls, floor etc.) if they don't have rigidbody attached to them unless you're knowing what you're doing 100%.
Upvotes: 0