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 bradmstu · Jan 30, 2013 at 03:36 AM · camerajavascriptsidescrollershake

2.5D SideScroller - Camera shaking on the Y Axis

Okay this is my first time using javascript and unity3D to make a game. I've been chipping away for about a week now and i feel i've made good progress. I have scripted my character movement and enemy movement as well as set up a score counter. One of the first scripts i made, was a script to follow my hero around on the platforms. All week every time i run a test the camera has worked perfectly. No problems. However last night it started to shake out of controlonce my character went about 120 on the Y axis. Here is the script i am using to follow my player around:

     public var Player : Transform;
 
 
     function Update(){
           transform.position.x = Player.position.x;
          transform.position.y = Player.position.y;
               
      if (Player.position.y < 100){
         transform.position.y = 100;
      }
 
             
   }

So the first thing you may suggest is the shaking isbeing caused because i've asked the camera to sit up higher than the player if he is on the ground. That's what i thought, and it seems straight forward, however like i said, this script has been working flawlessly for me all week and now all of a sudden if my player goes higher then 120 on the Y axis (100 is his position and his height is 20) the camera starts shaking around. Almost like it can't decide whether it should sit at the fixed position of 100 or whether it should start following the players position. Another theory i have is that the camera is trying to position itself with a second variable, or a second instance of my Player variable. But i can't see that anywhere in any inspector.

I think a cleaner script would be to change the if (Player.position.y < 100){ to something like if (Player.is Grounded){ but javascript doesn't like that line.

Sorry for the wall of text, thanks for any help and advice.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by golemsmk · Oct 29, 2013 at 06:00 AM

The answer can be easy: prefab. When you make the camera follow the character that way, the position will be the position of prefab and its instance, and that makes a bug. You can choose the prefab of character in Hierarchy, go to GameObject menu, and choose Break Prefab Instance. Then you re-drag-and-drop the character in your script again, and that should work.

Anyway, tick this answer right if it help you, for other people don't waste the time for looking around.

With me, you are only one who have the same problem with me on Unity Answer that I found.

P/S: and I very like the text wall, too.

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

10 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

Related Questions

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Finding Positions of other game objects and using them as an argument for an if statement. 0 Answers

OnMouseDown on what? Camera Movement Help. 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