Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 andreacaldwell · Apr 24, 2015 at 06:10 PM · 2dcartutorial

Simple 2D Car Game

I only started basic coding last Sept. For college, we have to make a 2D game of our choice. I chose to make a car game, but I having trouble with the script and making the car move forward. I have been searching online for the past 2 hours trying to find car tutorials, but I couldn't find any ones with script, and when I did, I had to pay for them (being a student I don't really have money). Are there any simple tutorials around to help me out? Or can anyone give me any help at all?

Comment
Add comment · Show 2
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 KitCoo · Apr 24, 2015 at 10:36 PM 0
Share

I am Pretty new to Unity as well I would imagine that to do 2d car would be as simple as just a sprit character as well. Personally I have not specifically looked for 2d car tutorials, but I think the best place for you to begin would be the Unity Tutorials they offer great info and never cost money. $$anonymous$$ore important is that it is good information. So check out the 2d tutorials and build a 2d character controller and if I am not mistaken just a sprite should work with some inventive colliders. Just a thought but again I am pretty new myself. Hope that helps and does not hinder.

avatar image KitCoo · Apr 25, 2015 at 12:23 AM 0
Share

ok so some testing and I have used the 2d wheel collider. I put box gave it a rigid 2d. $$anonymous$$ade to wheels with the joystick sprites. Gave them rigid 2d as well. now I gave both wheels 2d wheel joint. Ok now I had success when I did not parent the wheels to the box. Another thing to note is that the Wheel joint is a joint not suspension. Now put the rigid 2d into where the wheel joints ask and here you have a platform on wheels. add force to the motor and it rolls. After that if you want to control your car you will have to build a simple motor script and attach it to the box. Again Am Still $$anonymous$$ind of noob myself. But have had success in what I need the wheel joint for just platform on wheels I add motor power to make it move for platform obstacle. Hope this with the tutorials will get you on your way good luck friend.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by LittleJohnGames · Apr 26, 2015 at 07:09 PM

I have changed the script to set up EVERYTHING. Just drag and drop onto your car sprite and it will work. HERE IT IS

 @script RequireComponent(Rigidbody2D)
 
 var Speed : float = 5;
 var RotationSpeed : float = 3;
 
 function Awake(){
     GetComponent.<Rigidbody2D>().angularDrag = 1;
     GetComponent.<Rigidbody2D>().drag = 1;
     GetComponent.<Rigidbody2D>().mass = 1;
     GetComponent.<Rigidbody2D>().gravityScale = 0;
 }
 
 function FixedUpdate() {
     var ZRotation : int = Input.GetAxis("Horizontal") * RotationSpeed;
     var YSpeed : int = Input.GetAxis("Vertical") * Speed;
     GetComponent.<Rigidbody2D>().AddTorque(-ZRotation, 0);
     GetComponent.<Rigidbody2D>().AddForce(transform.up * YSpeed);
     
 }

This is once again Javascript so remember to put it in a JS file. It handles all of the basic player controls for a 2D car game, so should be enough to get a car moving. As for other elements, I am not too sure either. Looking at a basic 2D game tutorial should be enough to start up the game.

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 LittleJohnGames · Apr 26, 2015 at 07:22 PM 0
Share

I edited the script to use a 2D rigidbody and set up everything required, but do not have it as it is on my PC. I'll try and get it up here

avatar image
0

Answer by DavidZendle · Apr 24, 2015 at 10:44 PM

When it comes to car tutorials, there's always the old Unity Studios one

I remember making a racing game a while ago, and I found it pretty helpful - of course, though, it's 3D, so your mileage may vary.

However, for 2D car tutorials, I'm at a loss. You could always start out with a general overview and work your way up? Having a good grasp of the basics always helps in the long term!

Comment
Add comment · 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
0

Answer by gpaulguilfoyle · Jan 14, 2020 at 06:48 PM

Here is an awesome tutorial on how to make a unity 2d racing game. The tutorial covers unity ads as well for monetizing a truly begin to finish unity racing game tutorial.

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

how to make 2D physics-based car / motorcycle game? 2 Answers

Movement based on rotation 1 Answer

Attempting to add wheel friction to a 2d car 1 Answer

Saying the car is riding wrong way 0 Answers

Making a race car positioning system 5 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