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 /
  • Help Room /
avatar image
0
Question by ozan036777 · Apr 22, 2019 at 07:30 PM · scrollviewscrollingautomaticmario

How to do an automatic scroll level in a 2D mobile game like in mario's game ?

Hi i just would like help for my project, I'm want to make an little game for android, I would like to know how to do an automatic scolling level like mario ( https://www.youtube.com/watch?v=wbwl7-JiTvA ) and if possible, an scrolling level which the camera goes from up to down. Thanks for helping me.

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 ozan036777 · Apr 24, 2019 at 03:13 PM 0
Share

thanks you very much.

avatar image highpockets ozan036777 · Apr 24, 2019 at 09:23 PM 0
Share

No prob, if it solved your problem, please mark the answer correct

2 Replies

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

Answer by highpockets · Apr 22, 2019 at 07:29 PM

Just add this script to your main camera:

 public float speed; //adjust this in the inspector to make the scroll speed less or more
 
 void Update(){
 
 transform.Translate( 0, -speed, 0);

 }


Comment
Add comment · Show 3 · 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 highpockets · Apr 22, 2019 at 07:34 PM 0
Share

Just to elaborate, if you put positive speed as the y float parameter, it would scroll up, if you put it on the x parameter, speed would go right, -speed would go left. Hope that helps. Cheers

avatar image ozan036777 · Jun 13, 2019 at 11:07 AM 0
Share

hi @highpockets
i used the script you gave me for my game it works very well, but now i have another problem i can't slove. when i give the scipt to a object, and when I rotate the object that contains your script, the object take another direction and does not go up to down as it should do.

(i decided to make object fall down in the players screen rather than make the play and the background go up because of a script who block me in order to not go out of the screen, i let you an image if intersted ) alt text

my-game.png (38.3 kB)
avatar image highpockets ozan036777 · Jun 13, 2019 at 11:24 AM 0
Share

I'm not exactly sure I understand what you are saying here, but I think you mean that you assume that if you rotate the object that the script above is attached to, it should still move in the same direction, but the method translate will move according to the transform's local space unless you set it to world space:

https://docs.unity3d.com/ScriptReference/Transform.Translate.html

If you want it to always go up in world space (+y) or down in world space (-y). Then you can do it like this:

 public float speed; //negative value for down and positive for up
 
 void Update()
 {
 speed = speed * Time.deltaTime;
 transform.Translate(0,-speed,0, Space.World); //Space.World sets the translation to worlds space
 
 }
avatar image
0

Answer by ozan036777 · Jun 13, 2019 at 05:24 PM

yeah that is what i wanted and you helped me again, thanks you ! again

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 ozan036777 · Jun 25, 2019 at 02:11 PM -1
Share

Hi, @highpockets I have another question, how do we stop the scrolling when the "player" get Destroyed with the line code:

   Destroy(collision.gameObject);

and if possible, add a texte when we stop the scrolling

I hope i was clear this time and thanks you, again

avatar image highpockets ozan036777 · Jun 25, 2019 at 04:09 PM 0
Share

$$anonymous$$aybe you want to just pause the whole game?? If so, you can use Time.timeScale = 0.0f;, but if you still have other things dependant on frame rate, you can make the scroll scripts inherit from a base class and just set the speed of each instance of the base scrolling class to 0.0f. Or you can give each of the scrolling objects a tag called “scroll”, then use FindGameObjectsWithTag() to get an array of the objects and set each scroll script speed variable to 0.0f..


Personally, I would do it with the base class option or you can also use an interface to do the same

avatar image ozan036777 · Jun 27, 2019 at 12:46 PM 0
Share

what you asked is just too hard for the begginer I am. I really don't know how to time.scale. or can we just stop the game, or scrolling just by collision ? I almost finished my game but i don't know how to say, for exemple, If a player get collision, then stop scrolling. or what ever ...

avatar image highpockets ozan036777 · Jun 27, 2019 at 01:00 PM 0
Share

If you want to stop all of the scrolling objects and they are each controlled by individual instances of the same script, you either have the option of pausing the game with Time.timeScale = 0.0f; which is quite simple, or you need to iterate through each instance and stop the scrolling. If you just want to stop the object in the collision, then you get the component and stop the scrolling. I don’t see another option

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

169 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

Related Questions

How to make a scroll rect NOT overflow? 1 Answer

Scroll list isn't working,Scroll list not scrolling. Can someone help me? 0 Answers

move automatically to item in scroll rect 0 Answers

Problems with dynamically adding and scrolling to Scrollview 0 Answers

How do I enable buttons that are within a scroll view? 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