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 aleem.razzaq09 · Dec 23, 2013 at 11:15 AM · 2dunity4.3

2D Car game scene confusion

Hi, I am new bee in Unity 3d. I want to make 2D Car game. First I am trying with few test that am I able to make this racing game or not. The game concept is very simple car goes just straight and it if cross others car it get points and if hit then Game Over just like motor bike's game "highway rider". So I am confuse that Should I need to make whole long scene where my car travel one point to another or is this possible that I can create just few long scene and repeat it, I'll be happy if second option can achieve because this is easy for me to create graphics and if Yes then how can achieve my goal. Please help me and suggest me better way to do this. Thanks in advance.

Comment
Add comment · Show 3
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 Spinnernicholas · Dec 23, 2013 at 05:27 PM 0
Share

Team_26 is definitely pointing you in the right direction, but it is a bad idea to loop gameplay by reloading the level. Ins$$anonymous$$d, just reset the car's position to the beginning of the track.

Also, you will need to leave some room at the beginning and end of the track so that the road looks continuous.

avatar image aleem.razzaq09 · Dec 24, 2013 at 05:23 AM 0
Share

@spinnernicholas I 100% agree with you, it should be like this as you are suggesting, but what If, if I'll animate road and other car move backward and my(or current playing user) car will be in idle(or animate to looks like it traveling on road) so when other car(those are co$$anonymous$$g backward) hit my car then game over, what do you think its a good idea? and also how can I judge that my car pass the other car so that I can assign specific number to current playing user.

avatar image aleem.razzaq09 · Dec 24, 2013 at 06:46 AM 0
Share

@spinnernicholas I am still confuse how to create scene in Unity3d for 2D car Game like to draw road and others, can you please suggest me any video tutorial to create 2D car game scene, $$anonymous$$indly don't suggest me any other scene videos, it'll be better that its related to 2D car game.

4 Replies

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

Answer by Spinnernicholas · Dec 24, 2013 at 04:51 PM

  1. The main reason I would move the car and not the road, is that if you move the car, you are only moving one object, otherwise, you have to move everything except the car.

They have the same performance though, so it might be a better idea to to keep the car fixed. The best way to do this is create a gameobject that holds the road and all of the other objects(cars, environment,...) except the player car. I would probably still use a trigger to check when the car reaches the end of the road.

  1. The 2D tools are really new and there are not really an good tutorials yet that I've seen.

First, set the main editor window to 2D mode. That will lock the camera to XY 2D mode. Then, create sprites from the menu bar at the top. Other than that, it's exactly the same as 3D.

Make sure and pay close attention to the hierarchy. That is the transform hierarchy of the scene. Each transform inherits the transform properties of it's parents.

Comment
Add comment · Show 8 · 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 aleem.razzaq09 · Dec 26, 2013 at 06:45 AM 0
Share

Thanks @Spinnernicholas. Two things here which I need to know first there is flexibility on hold player car object and move other objects(with animated road) approach because I can create as many as I want opponent car and just reverse their position, ins$$anonymous$$d of first create scene and then repeat scene I think this will cause to show same scene again and again. Second thing is that after implementing your suggested approach just to move player car object and also move camera with it but what happening my car flicker and looks like that after some specific time car redrawing its self I don't know why this happen.? kindly check my below code which I wrote in FixedUpdate() function and suggested me better thing on this. Thanks again.

 transform.position = new Vector3(transform.position.x,transform.position.y,Time.fixedDeltaTime *speed);

     carCamera.transform.position = new Vector3(carCamera.transform.position.x,carCamera.transform.position.y,Time.fixedDeltaTime * speed-2);

where speed=2.0;

avatar image Spinnernicholas · Dec 26, 2013 at 05:55 PM 0
Share

$$anonymous$$ake the camera a child of the car, then you don't have to manually move the camera every frame.

avatar image Spinnernicholas · Dec 26, 2013 at 06:05 PM 0
Share

And I would probably use a velocity vector for elegance:

 Vector3 velocity = new Vector3(0f,0f,speed);
 transform.position += Time.fixedDeltaTime * velocity;
avatar image aleem.razzaq09 · Dec 27, 2013 at 06:50 AM 0
Share

Thanks @Spinnernicholas, I am using Perspective Camera and I think the issue is which also mentioned in my other question's answer "If you are using a perspective camera, its likely that the road's center point becomes closer to the camera than the car's center point. Since the road is therefore "closer" than the car its drawn on top." In this Post "http://answers.unity3d.com/questions/602426/which-camera-projection-should-i-use-for-2d-game-i.html" I am pretty sure this is the problem, could you please guide me what should I do to tackle this issue.

avatar image Spinnernicholas · Dec 27, 2013 at 06:14 PM 0
Share

Oh, yeah, that is an issue. I haven't messed with them, but you can use Sorting Layers to set the rendering order for sprites.

If you look at the Sprite Renderer, you can see sorting layer in it's properties.

You will need to read up on Layers and how they are used as sorting layers, but this is the way to go. It is exactly what Unity designed it for.

Show more comments
avatar image
0

Answer by Team_26 · Dec 23, 2013 at 11:49 AM

You can create a street scene and when player is at the end of the street, load the level again. At first add a new object at the end of the scenea and remove "Mesh Renderer" component from this object. Now add a tag to this gameobject called END_GAMEOBJECT and make a simple script:

void OnTriggerEnter(Collider other)

{

if(other.gameobject.tag == END_GAMEOBJECT) { Application.LoadLevel("NAME_OF_YOUR_SCENE"); }

}

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 aleem.razzaq09 · Dec 24, 2013 at 06:42 AM 0
Share

@Team_26 I am still confuse how to create scene in Unity3d for 2D car Game like to draw road and others, can you please suggest me any video tutorial to create 2D car game scene, $$anonymous$$indly don't suggest me any other scene videos, it'll be better that its related to 2D car game.

avatar image
0

Answer by Team_26 · Dec 23, 2013 at 12:00 PM

It's possible that you can make a street in your scene and invisible gameobject at the end of this street. To make this object invisible, you must remove from it component called "Mesh Renderer". Now you must add to this gameobject tag called STREET_END (for example) and make a simple script:

void OnTriggerEnter(Collider other) { if(other.gameobject.tag == STREET_END) { Application.LoadLevel("NAME_OF_YOUR_SCENE"); } }

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 Spinnernicholas · Dec 23, 2013 at 04:52 PM 0
Share

Really, 2 answers? Shakes Head

avatar image
0

Answer by Prd_Animator · Dec 27, 2013 at 07:41 AM

http://unity3d.com/learn/tutorials/modules/beginner/2d

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

19 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

Related Questions

Change object's clone tag after creation. 1 Answer

How to move ball as fast as it pulled back for 2D game in Unity 4.3 0 Answers

Which Camera projection should I use for 2D game in Unity 4.3 3 Answers

How to handle camera view for avoiding jerking. 0 Answers

Moving object show jerks in middle of Image. 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