- Home /
Vehicle Rigidbody Movement / Collision
I've decided to use a non-kinematic rigidbody for the vehicles in my game. Just to note, they are secondary to the main game (which takes place on the rooftops of nearby buildings).
I have traffic nodes littered throughout the streets to direct the vehicles where to go. Some of these nodes represent stop signs (they'll cause the vehicle to come to a stop for a few seconds before casting a ray and then proceeding to turn), while others are controlled by traffic lights.
I need the vehicles to be able to collide with each other, nearby buildings (drivers may be startled and simply veer off road into buildings, trees, etc), and other debris that may have inadvertently fallen into the road (aka imagine the player shooting down scaffolding on top of a building).
My question, plain and simple, is: having described my needs above, what is the best way to move my vehicles so they move smoothly, accurately (aka easy for me to have turn and follow roads without veering into other lanes), and react to physics objects and possibly explode?
I'm not entirely sure how I want to handle vehicles turning. I was thinking of maybe using a curve and just interpolating them along the curve until the end, at which point they continue their normal driving behavior, moving along to the next node down the street. Of course, deciding now to use rigidbodies throws a possible fork in that plan also, since I'm unsure how to move rigidbodies!
If anyone can share some educated opinions and suggestions, I'd greatly appreciate it! If there are any caveats, please share those also, I'm really trying to write a fairly clean but robust system but I have limited-to-no experience using physics!
Thanks! -Matt
edit - Also, I understand the FixedUpdate happens less frequently, which could result in jitter...but using rigidbodies, and possibly AddForce, is FixedUpdate a better spot to move the vehicles? Is AddForce a good option? I need to be able to tell if/when the vehicles should come to a stop so they don't overshoot stop signs...and how on Earth would I simulate breaking so they don't stop on a dime but end up at 0mph at the point they need to be??
Nope, I wrote it correctly...I'm NOT using kinematic rigidbodies, I'm using NOR$$anonymous$$AL ones. I want the precise movement of a kinematic rigidbody (doesn't get more precise than updating position directly in every regular Update) but the realistic collision detection/reaction of normal rigidbodies.
It's important that I can feel confident that my vehicles won't slide out of their lane as the simulation runs for long periods of time. They need to be reliable / predictable...until they're hit by a falling crane of course. :)
AddForce seems difficult to keep control over. If I need the vehicle to stop at a stop sign, how could I know how much force to apply as a brake and how often so when they reach 0, they're actually at the stop sign?
Answer by Maulik2208 · Mar 28, 2013 at 06:55 AM
i think all you need is AI Driver Toolkit and you are all set to go......
1)---->tutorial on AI in vehicle
2)---->tuorial on AI Driver Toolkit
3)---->another tutorial on AI Driver Toolkit
DON'T FORGET TO MARK THE ANSWER IF FOUND USEFUL.......CHEERS FROM INDIA.........
I've got a lot to do at work today (on our other project), but as soon as I get some free time I'll take a look. I glanced at the first link and within 3 $$anonymous$$utes it sounded like that tutorial was implementing exactly what I need! So this sounds promising!
Your answer
Follow this Question
Related Questions
Collisions causing Rigidbody to go Haywire and move randomly. 1 Answer
Issues Making Character Move With Rigidbody 1 Answer
Simple Movement Game: Physics vs Manual Collision Detection? 2 Answers
Calling Rigidbody.MovePosition, no movement at all 4 Answers
Player getting stuck in ground (3D) player has Rigidbody, and Box Collider, world is Mesh Colliders 0 Answers