- Home /
Problem: Cube goes through other objects.
Okay. I solved all my previous problems. And hopefully this will be my last. (at least for this project) I'm making an endless runner and my player doesn't move. Instead the obstacles are moving. To get this working my teacher advised me to remove all the rigidbodies and rewrite the script. Now only the player(the cube) has a rigidbody because it needs constraints and gravity. The problem is that my cube passes through the obstacles. And it needs to be pushed back. Every object has a box collider. It should work. This is probably a very stupid problem. But I can't seem to fix it.
Check each object (the player and the road prefabs) to see if isTriggered is checked on them. If so, uncheck it.
The problem may be the speed of the objects. Try to decrease the Fixed Timestamp and $$anonymous$$aximum Allowed Timestamp (Edit -> Project Settings -> Time). Also move the detection code in FixedUpdate(), and adjust the Rigidbody settings.
If this is too cpu intensive, you should simulate the detection. Use a Raycast to find your position relative to the obstacles, calculate the distance you moved from the last frame. If that distance is smaller than the distance between the character and the obstacle you should stop the movement (then the collision will be detected).
Your answer
Follow this Question
Related Questions
How do I find the point of contact on a box collider? 1 Answer
2d collision with "unwalkable" objects 2 Answers
Is it possible to scale one face of a box collider?? 2 Answers
Box collider with rigid body yet enemies still pass through each other. 1 Answer
[2D Platformer] How do i make a platform that is only active when the player is standing on it? 1 Answer