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 JJNCreator · Jul 03, 2012 at 07:14 PM · c#cameraguitextycredits

Credits Camera Script

hey guys. i have a credits level with gui text, a camera and two empty game objects. i want the camera to move down and show the gui text while moving down on its y axis. i also made this c# script:

 using UnityEngine;

using System.Collections;

public class CreditsCamera : MonoBehaviour { public Transform startingTarget; public Transform endingTarget; public float cameraSpeed;

// Use this for initialization void Start () { if(startingTarget == null) Debug.LogWarning("There is no starting target for the camera");

if(endingTarget == null) Debug.LogWarning("There is no ending target for the camera");

}

// Update is called once per frame void Update () {

} }

do u think you can help me? c# would be good

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 Luci85 · Jul 03, 2012 at 07:16 PM 0
Share

Basically you want to change the transform.position.y of the camera from the startingTarget till it reaches the endingTarget. Right?

avatar image JJNCreator · Jul 03, 2012 at 07:18 PM 0
Share

right. and as its doing that it shows the gui text

3 Replies

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

Answer by _EdzUp_ · Jul 03, 2012 at 09:16 PM

I have uploaded a package of the scene and script to here as some of the code doesnt seem to appear properly this is a unity package so should be just import into anywhere and it should run in the editor fine.

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 JJNCreator · Jul 03, 2012 at 09:51 PM 0
Share

its running okay. thanks

avatar image
1

Answer by _EdzUp_ · Jul 03, 2012 at 07:50 PM

Ok so what your doing is basically moving the camera down and displaying the relevant text as required as the camera passes by? If thats what your trying to do what I would do is place all your strings in a array and then update the GUIText as required.

You could do it by 1) moving the camera with transform.translate to move the camera slowly down

When it moves down a line then do: 2)increment a counter so the game knows you have moved down a line 3)change all the GUIText with the new data from the array 4)move the camera back up then start again (1)

keep doing that until you have displayed the entire credits and when thats done reset the line counter so it runs through again OR go back to main menu.

The main bonus with doing this is you wont need hundreds of GUIText entries and its easy to change the array than rehashing all the GUIText entries then it is to have hundreds of entries it will also keep the ram requirements of your game down.

Comment
Add comment · Show 5 · 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 JJNCreator · Jul 03, 2012 at 08:00 PM 0
Share

could you put that in some code? thanks

avatar image _EdzUp_ · Jul 03, 2012 at 08:09 PM 0
Share

I use js is that ok for your project?

avatar image JJNCreator · Jul 03, 2012 at 08:10 PM 0
Share

i would use c#, but js is ok too

avatar image _EdzUp_ · Jul 03, 2012 at 08:41 PM 0
Share

Ok I will knock something together for ya, it wont be pretty but it will hopefully explain it enough for you to get a understanding from it :)

avatar image JJNCreator · Jul 03, 2012 at 08:57 PM 0
Share

okay. thanks

avatar image
0

Answer by _EdzUp_ · Jul 03, 2012 at 09:03 PM

Here ya go its not elegant and there are probably hundreds of ways to do it but this way you wouldnt have to have hundreds of GUIText's to scroll through.

#pragma strict var ScreenGUI:GUIText[]; //assign GUIText arranged in scene to ScreenGUI var CreditText:String[]; var Cam:Camera; //assign scene camera in inspector var CurrentLine:int =0; //Current line of CreditText array var TextMoved:float = 0.0; //how far the text has moved for resetting var ScrollSpeed:float = 0.0025; //Scroll speed of the text

function Start () { //setup the CreditText array to whatever length you need with extra lines so it scrolls //onto the screen and off the screen before being reset CreditText = new String[ 40 ];

 //Initialise the array
 for ( var CTPos:int =0; CTPos<40; CTPos++ ) {
     CreditText[ CTPos ] = "";
 }
 
 //set the credits text here this will set the array so when its displayed there is 
 //something to display
 CreditText[ 10 ] = "A test";
 CreditText[ 11 ] = "To see if it works";
 CreditText[ 13 ] = "Here is a simple credits";
 CreditText[ 14 ] = "text scroller!";
 
 setGUIText( 0 );            //set the first lines of text

}

function Update () { //update the positions of the GUIText on the screen for ( var SGP:int = 0; SGP<=ScreenGUI.Length -1; SGP++ ) { ScreenGUI[ SGP ].transform.Translate( Vector3( 0, ScrollSpeed, 0 ) ); } //adjust the check variable TextMoved += ScrollSpeed;

 if ( TextMoved &gt;0.1 ) {
     TextMoved =    0.0;        //reset the TextMoved variable
     CurrentLine++;            //Increment the line
     setGUIText( CurrentLine );
     //move it all back again
     for ( SGP = 0; SGP&lt;=ScreenGUI.Length -1; SGP++ ) {
         ScreenGUI[ SGP ].transform.Translate( Vector3( 0, -0.1, 0 ) );
     }
     if ( CurrentLine&gt;CreditText.Length ) CurrentLine =0;
 }

}

function setGUIText( line:int ) { //This function will setup the GUI text var CLine:int = line;

     //the line+ScreenGUI.length means we can change the length of the array and it wont
     //break the code.
     for( var TAP:int = 0; TAP</code></pre>

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

7 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

C# 2d Instantiate GUIText and lock it to position on map, not to follow camera. 1 Answer

Distribute terrain in zones 3 Answers

Disable Camera Movement,Stop camera movement 0 Answers

Choppy Camera Follow 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