Aiming the Car
Applying force to a rigid body for the push is straightforward—just add force at the push position. The real challenge lies in aiming and ensuring the car is positioned steadily on uneven terrain before the push. With all its unexpected complexities, I think these mechanics are worth a deeper dive.
At the start of each step, the car is lifted slightly above the terrain, allowing it to be moved and rotated freely without colliding with the ground. Its altitude is set by performing a box cast downward and positioning the car just above the highest detected point within the casting area. This area spans the track’s width with extra margin to accommodate rotations. Overhanging objects like bridges and checker flags are excluded from the cast, ensuring cars can be placed beneath them.
During aiming, the car’s rigidbody physics are disabled to prevent unintended movement or rotation. However, collision triggers remain active to detect overlaps with non-terrain objects, ensuring the car cannot be positioned on top of them.
Once aiming is complete, physics are re-enabled, and the car drops onto the terrain. Wheel colliders are locked in place to prevent rolling, but the car can still sway on uneven ground — an unintended side effect that has since become a useful gameplay element.
While this approach works for the first version of the game, it has limitations that will become problematic as I introduce more dynamic track elements. Additional mechanics will be needed — something I'll dive into in the next post.
Get Hanaa
Hanaa
A turn-based racing game
Status | In development |
Author | mobilelast |
Genre | Racing |
Tags | Casual, Multiplayer, Physics, Turn-based, Unity |
Languages | English |
More posts
- How to Deadlock Yourself in a Racing Game9 days ago
- It's the Law!19 days ago
- Showing it in Motion22 days ago
- Sandbox Photogrammetry26 days ago
- The Name of the Game30 days ago
- The Beginning34 days ago
Leave a comment
Log in with itch.io to leave a comment.