- Home /
How to anchor object on ground?
Hi.
I am beginner in unity and just experimenting with the game engine. I'm building a Bumper Cars game. I have 2 bumper cars set up with controls for each one.
Problem: when they collide, they "roll away from each other" like a ball, rather than skidding like bumper cars, and sometimes end up in odd positions (eg. upside down/sideways) and I cannot get them back up.
I have tried various rotatio-locking scripts and rigidbody constraints, but still cannot achieve the desired effect.
My bumper car is self drawn in Blender, so it is an irregular surface.I have ad to make the object not "Kinematic" to make it not go through the walls which I have added to the scene and to allow proper collisions with them. Any help is much appreciated,
Lorenzo
Answer by ahsen35813 · Apr 05, 2020 at 02:08 PM
Just to confirm, have you tried constraining x and y rotation in the Rigidbody component? If you do this the bumper cars should be able to rotate in the y axis and move in all directions, but always stay level. If on top of that, you want to make sure that the bumper cars do not bounce up and down, you can also freeze position in the y axis.
I hope this helps!
Yes, I have tried that. However, it still shows the same behaviour...
@ahsen35813 It does get slightly better with those constraints, but not exactly the desired effect yet. Whenever the player is scraping the wall, for example, there are instances where their bumper car just spins irrespective of whether I have the constraints set up. ...
The bumper car spinning when scraping a wall makes sense, because the wall would be stopping the side of the car, and the other side would keep going, resulting in a spin. Two potential solutions could be to either freeze rotation in the Y-axis as well, or adding a physics material with friction set to 0 to the bumper car. Or you could do both.
Your answer
Follow this Question
Related Questions
Rigidbody.SweepTest - Local or Global axis? 1 Answer
No more collision while Quaternion.Slerp 0 Answers
Collisions While Rotating Objects Without Character Controllers 1 Answer
Character Controller falls through moving/rotating platforms (Not A Duplicate Post) 1 Answer
Odd collider rotation 1 Answer