- Home /
Are y-axis wheelcolliders possible?
The scenario:
I have a car using a standard setup I think. Four wheelCollider wheels and a rigidBody at the top of the hierarchy.
The goal:
I want to add a fifth wheelCollider, but I want this one to be spinning around the y-axis. Like a spinning top, not like a spinning coin.
The why:
My car is getting stuck head-on facing walls and fences and corners. I want to add a smart wheelCollider to the front of my car, center-wheel height, that can effectively drive me out of those situations.
The problem:
I can add a wheelCollider to a new, separate gameobject with its own rigidBody and rotate that gameobject's transform to align the wheelCollider as I need it.
But I can't figure out how to add that system into my existing car.
If I drag it in as-is, it won't move with the car because it has its own rigidBody.
If I remove the rigidBody the wheelCollider snaps back to the car's own wheel alignment, ignoring the gameobject's transform.
If I keep it as a separate gameobject and connect them with a fixedJoint, well it was hard to see what it was doing but on some larger scale tests it was clear that collisions with the fifth "wheel" were doing crazy stuff with the attachment and were not treating the car as though it is "hard" connected. And the physics always end up exploding.
The question:
Is there a clever way to do this? Or is there a better way to get vehicles -- that have NO reverse and a 40 degree turn radius -- out of "stuck" situations?
Thanks.
Answer by cjdev · Aug 18, 2015 at 08:33 PM
Instead of trying to use another wheelCollider here why not send a raycast in front of the vehicle and have it turn when it comes too close to an obstacle? Alternatively, if you're looking for the vehicle to hit the wall then move away, wait for the raycast to detect a closer distance and move the transform of the vehicle via scripting.
The first idea could just turn the car into another wall.
The second idea is interesting though. I hadn't thought of physically moving the car's transform. Something to try if the horizontal wheel isn't possible.
Your answer
Follow this Question
Related Questions
Wheel Collider - Mesh/Box Collider Problem 0 Answers
Car - WheelCollider - Why the side is getting up? 2 Answers
car not moving straight 3 Answers
how to set initial speed of vehicle 1 Answer