Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by parth_vadera · Sep 18, 2017 at 06:41 AM · unity 5physicscar physicsturnquick

Car physics like cartoon cars

Hi guys,Please help me I'm making a multiplayer cartoon (low poly) type 3d car game where all cars fights with each other. For that, I need my car physics like turning quickly and dodging bullets. I don't want to use wheel colliders (I don't need real car physics) I tried finding on the everywhere but can't find the physics I really need. How can I achieve this physics?

Car physics exactly like this game : https://play.google.com/store/apps/details?id=com.notdoppler.crashofcars&hl=en

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vubb3 · Sep 18, 2017 at 06:45 AM 0
Share

Try use rigidbody and make it like a character movement. Rotation and position etc.

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by OSharp · Nov 12, 2017 at 05:40 PM

Here is a script I have been working on - It doesn't require any wheels so just make a cube with rigidbody. It has basic drifting and is simplistic (and seriously needs some working on!) but I quite like it as I have just started public float movementSpeed; public float turnSpeed; public float drift; void Start() { GetComponent<Rigidbody>().centerOfMass = new Vector3(0, -3, 0); } void Update() { transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime * drift * -1, 0f, Input.GetAxis("Vertical") * Time.deltaTime * movementSpeed); if (Input.GetKey(KeyCode.A)) { transform.Rotate(0, turnSpeed*-1, 0); } if (Input.GetKey(KeyCode.D)) { transform.Rotate(0, turnSpeed, 0); } if (Input.GetKey(KeyCode.W)) { drift = 30; } else { drift = 0; } }

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image parth_vadera · Nov 13, 2017 at 04:03 PM 0
Share

Thanks for the answer! I managed to do some tweaks to the wheel colliders just for moving and rotating the car so it looks a little realistic and more cartoonistic at the same time but still needs to be perfect. So I tried your code and its closer to how I actually wanted!! I also wanted to drift the car and now I'll be able to do it. Thanks to you!

avatar image
2

Answer by IndievdB · Sep 18, 2017 at 07:13 AM

This seems very do-able. All you need is some kind of simple collider(s) covering most of the car, a script for movement, and a RigidBody for physics. The RigidBody, with a bit of tweaking will give you the momentum and feel of that game pretty easily.

Your movement script should add force or somehow alter the velocity of your car. When the player clicks forward, add force to the RigidBody in the direction the car is facing. When the player clicks left/right, slightly rotate the car in that direction. Something like this can act as a template:

 void Update()
 {
     float newRotation = transform.localEulerAngles.y + Input.GetAxis("Horizontal");
     transform.localEulerAngles = new Vector3 (0f,newRotation, 0f);
 
     Vector3 input = (transform.forward * Input.GetAxis("Vertical"));
     rigidBody.AddForce (input* Time.deltaTime * 10, ForceMode.Impulse);
 }
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image parth_vadera · Sep 18, 2017 at 07:52 AM 0
Share

Thanks man, I think I'm getting there but sometimes I find my car floating in air! I can't Freeze Y position because I have some features when I want to add force car in the air.

avatar image IndievdB parth_vadera · Sep 18, 2017 at 04:49 PM 0
Share

If the car's RigidBody has gravity enabled, it should fall. If there is a ground below it which also has a RigidBody (with gravity disabled), it should catch it. If they both have a collider. Side-note, RigidBody's can also have Physics $$anonymous$$aterials that adjust their friction and bounciness. Let me know if there are still problems.

avatar image parth_vadera IndievdB · Sep 18, 2017 at 05:26 PM 0
Share

Ground has no Rigidbody but $$anonymous$$esh collider, car's Rigidbody has gravity enabled and is$$anonymous$$inematic disabled with a box collider around it. When car collide with a wall or something, it starts floating and then comes down slowly on the floor. I set the mass to 2000. With your code, I'm able to control car movement like I need but still I think it still needs more physics work. Can you give me more info on making it stable? Thanks!

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

183 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Similar movement to a game (look description) 1 Answer

How do you make an wire/rope type object and attach to 2 separate objects 1 Answer

How to apply frictional Torque 2 Answers

Physics.overlapSphere doesnt detect colliders,Physics.CheckSphere doesn't detect colliders 1 Answer

Problem is not Bouncing 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges