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 WesterlyCarrot9 · Apr 25, 2013 at 12:54 AM · javascriptcollidercubeupdown

Up and Down Cubes Shaking Issue.

Ok so i use the code below for my cubes to go up and down in the Y axis. I just want that simple thing. Up and Down so that my player (First Person Controller) can go up and jump to the next. The only problem is that when the player is on the cube, the cube or should i say all the cubes start shaking. Is there a way to fix this? Is there a simpler code?

 var maxUpAndDown : float = 1; // amount of meters going up and down
 var speed : float = 50; // up and down speed
 
 protected var angle : float = -90; // angle to determin the height by using the sinus
 protected var toDegrees : float = Mathf.PI/180; // radians to degrees
 protected var startHeight : float; // height of the object when the script starts
 
 function Start(){
     startHeight = transform.localPosition.y;
 }    
     
 function Update(){
     angle += speed * Time.deltaTime;
     if (angle > 270) angle -= 360;
         transform.localPosition.y = startHeight + maxUpAndDown * (1 + Mathf.Sin(angle * toDegrees)) / 2;
 }
Comment
Add comment · Show 5
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 WesterlyCarrot9 · Apr 25, 2013 at 11:54 AM 0
Share

um anyone?

avatar image robertbu · Apr 25, 2013 at 02:50 PM 0
Share

Try using LateUpdate() rather than Update() and see what happens.

avatar image numberkruncher · Apr 25, 2013 at 03:14 PM 1
Share

I had a problem like this in the past and found that using RigidbodyInterpolation.Interpolate helped a lot.

avatar image robertbu · Apr 26, 2013 at 04:34 PM 0
Share

@numberkruncher - good call. I'm betting that he has the camera tied to his player, so it's not the cubes that are moving, but the player and the camera, so it just appears that the cubes are moving.

avatar image WesterlyCarrot9 · May 02, 2013 at 12:43 AM 0
Share

Where should i put this?

0 Replies

· Add your reply
  • Sort: 

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

12 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

Related Questions

How to block dragging if collider hits 1 Answer

Weird Collision Detection with a Cube and OnCollisionEnter 2 Answers

How do I put a texture on my Cube using code (JavaScript) 1 Answer

Trigger Enter and Exit not working properly? 2 Answers

Object push character controller 2 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