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 MR-Juggler · Aug 28, 2013 at 03:07 AM · c#animationshadersgame object

Creating a road with horizon.

I am making a game in Android. Its a infinite runner. I wanted some help on the plane looking curved while loading new scenes. Like on turns in Subway Surfers.... I am scripting in C#. Thanks guys!

Comment
Add comment · Show 7
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 Lost_C4 · Aug 28, 2013 at 05:15 PM 0
Share

You need to create a random generator, that is placing GameObjects (Array) at a random Position.

avatar image MR-Juggler · Aug 28, 2013 at 05:23 PM 0
Share

I've not reached up to that point... I wanna bend the horizon.... For roads and such stuff... Clouds and fog are good ideas but I need to get further information on the avatar animation and its integration with the environment. Does the plane move or the character? I'm like intermediate with unity... The running part is most confusing...

avatar image Sajidfarooq · Aug 28, 2013 at 05:25 PM 0
Share

You could do either. Its easier to have the character move, and as @Lost_C4 said, randomly create GameObjects in front.

avatar image MR-Juggler · Aug 28, 2013 at 05:28 PM 0
Share

But how do I bend the road?? In my case the plane? (Road)

avatar image TrickyHandz · Aug 28, 2013 at 05:29 PM 0
Share

That depends on how your code is implementing the movement. Generally, you are moving the character in the environment and not the environment around the character. Though both techniques are possible, moving one object (the character) is less work than moving an entire environment.

I'm not sure what you mean by "bend the horizon". In the 3D environment, if you want a road to curve or slope, you have to build a that curve or slope into the models you are using.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Warville · Oct 15, 2013 at 10:39 PM

he wasn't asking for for that guys he wanted the road to bend in X and Y axis ,

the easier way to do that without need to modeling bended models is curve shader , i'm using it now, it's easy all you need to do is to control the X and Y offset value with yur code give it random number from -x to x when x = 0 then the road is straight, but i have only found a basic code that doesn't support lights and shadows if you find out how to add shdow and light to the shader please tell me ,

 Shader "Custom/Curved" {
         Properties {
             _MainTex ("Base (RGB)", 2D) = "white" {}
             _QOffset ("Offset", Vector) = (0,0,0,0)
             _Dist ("Distance", Float) = 100.0
         }
         SubShader {
             Tags { "RenderType"="Opaque" }
             Pass
             {
                 CGPROGRAM
                 #pragma vertex vert
                 #pragma fragment frag
                 #include "UnityCG.cginc"
                 
 
                 
                 
      
                 sampler2D _MainTex;
                 float4 _QOffset;
                 float _Dist;
                
                 struct v2f {
                     float4 pos : SV_POSITION;
                     float4 uv : TEXCOORD0;
                 };
      
                 v2f vert (appdata_base v)
                 {
                     v2f o;
                     float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
                     float zOff = vPos.z/_Dist;
                     vPos += _QOffset*zOff*zOff;
                     o.pos = mul (UNITY_MATRIX_P, vPos);
                     o.uv = mul( UNITY_MATRIX_TEXTURE0, v.texcoord );
                     return o;
                 }
      
                 half4 frag (v2f i) : COLOR
                 {
                     half4 col = tex2D(_MainTex, i.uv.xy);
                     return col;
                 }
                 ENDCG
             }
         }
         
         
         
         
         FallBack "Diffuse"
     }
Comment
Add comment · Show 2 · 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 MR-Juggler · Oct 16, 2013 at 02:56 AM 0
Share

Seems good but can you show example code to control it? I'm new to shaders...

avatar image MR-Juggler · Oct 16, 2013 at 06:42 AM 0
Share

I'm guessing that I have to apply it to the road material... I'm I right?

avatar image
0

Answer by Sajidfarooq · Aug 28, 2013 at 05:30 PM

Your ground should be created in "pieces", or tiles, as prefabs. Each one is a plane of the same size. The only difference will be the texture on top. You will have straight textures, and bent textures on some. When you need the road to bend, you instantiate the tile which has a bent texture on int.

This is what I am referring to:

alt text

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 MR-Juggler · Aug 28, 2013 at 06:34 PM 0
Share

Awesome man... Hope this works for for me.... Will let you know....

avatar image MR-Juggler · Aug 28, 2013 at 06:45 PM 0
Share

I'm getting The idea... $$anonymous$$y road will be some sort of a digital highway... So I will have to make the prefabs by myself right?? I'll try it out this weekend... If it works +1 for you my friend!! Gotta sleep now its like 12A$$anonymous$$ here lol.... Thanks....

avatar image Sajidfarooq · Sep 10, 2013 at 09:08 PM 0
Share

@boggartfly: If this worked for you, don't forget to mark this question as answered.

avatar image MR-Juggler · Oct 16, 2013 at 02:57 AM 0
Share

Doesn't work. Damn sure tried all variations. Plus I can't control it dynamically.

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

20 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Animation play in unity 5??? c# 2 Answers

Play anaimation when key pressed 1 Answer

Add two radius on the same shader 1 Answer


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