I've placed a car model in a map as "EntHumanPlayer". Here is the problem:
What should I do if I want to accelerate the car? Now it just move at a fixed speed. Do I have to explore Physics.cpp and are there any simple ways to implement the acceleration?
What should I do if I want the car to make reaction just like in the real world when it makes collision with a wall?
Thanks!
Where to start using physics engine?
-
- Posts:11
- Joined:2012-04-30, 09:00
Re: Where to start using physics engine?
Hi alansalexer,
to be perfectly honest, right now I'm a bit overwhelmed by your questions, because the answers potentially involve a lot of details that I had to dig myself into again after not having looked into the physics code for a long time.
At the same time, I'd need more details about your current code to really make a statement -- I'm in fact a bit puzzled how you made a car move, but not have acceleration or collision.
Let me try to come up with something reasonable anyway:
I think there are two options to implement this:
One is to use the existing player movement code as a basis. Obviously, this code is meant for a player walking on foot, but it provides very smooth movement and is well tested, comes with acceleration and friction, and can probably be tuned to mimic car physics relatively easily. Combined with proper models and sound, the result might be very convincing.
Another option is to try to use the physics system, based on Bullet Physics, for the car. (This is the option where I too had to do some reading first before being competent enough for proper answers.) This would require a lot more effort and probably the completion of ticket 113 for successful implementation, but it would allow for more realistic physics (e.g. each wheel individually). If you want to do something like this, for a start check out example map
to be perfectly honest, right now I'm a bit overwhelmed by your questions, because the answers potentially involve a lot of details that I had to dig myself into again after not having looked into the physics code for a long time.
At the same time, I'd need more details about your current code to really make a statement -- I'm in fact a bit puzzled how you made a car move, but not have acceleration or collision.
Let me try to come up with something reasonable anyway:
I think there are two options to implement this:
One is to use the existing player movement code as a basis. Obviously, this code is meant for a player walking on foot, but it provides very smooth movement and is well tested, comes with acceleration and friction, and can probably be tuned to mimic car physics relatively easily. Combined with proper models and sound, the result might be very convincing.
Another option is to try to use the physics system, based on Bullet Physics, for the car. (This is the option where I too had to do some reading first before being competent enough for proper answers.) This would require a lot more effort and probably the completion of ticket 113 for successful implementation, but it would allow for more realistic physics (e.g. each wheel individually). If you want to do something like this, for a start check out example map
TestPhysics.cmap
and related entity code in RigidBody.*pp
.Best regards,
Carsten
Carsten
Who is online
Users browsing this forum: No registered users and 34 guests