Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Jun 11, 2014 at 09:47 AM by ChrisJoosten for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by ChrisJoosten · Jun 11, 2014 at 09:22 AM · c#movementforces

Making a bubble level (not a game but work tool)

Hi, im trying to make a bubble level. But i'm having some issues. I got 2 objects where i check the difference in Z axis. I use this (psuede)code

     movement = randomObject1.position.z - randomObject2.position.z;
     bubble.transform.position = new Vector3(0f,0f,movement); //moves in Z direction

But the bubble keeps moving continuesly but i'm what I want is when the movement variable gets bigger/more/higher the bubble moves more to the left or right, but now it keeps moving continuesly with the speed it gets from movement. So my question is if you have any solutions for the movement. I maybe thought by adding forces or something but i have no clue how that works.

By the way.. this is a bubble level alt text

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

  • Sort: 
avatar image
3
Best Answer

Answer by ChrisJoosten · Jun 11, 2014 at 09:47 AM

Already fixed the problem I used standard transform.position and added forces against. This is my script.

     void BubbleMovement(){
         float xF1 = AdjustF1.transform.position.y;
         float xF3 = AdjustF3.transform.position.y;
         float movement = xF1 - xF3;
         float zForce = 0.1f;
         curPosZ = bubble.transform.position.z;
         if (locked) {

             if(movement >= 0.1f && curPosZ > minMoveZ){ 
                 bubble.transform.position = new Vector3(bubble.transform.position.x, bubble.transform.position.y, bubble.transform.position.z + (movement * Time.deltaTime / 50f) );
                 bubble.rigidbody.AddForce(0f,0f,-zForce, ForceMode.Force);
             }
             if(movement <= -0.1f && curPosZ < maxMoveZ){
                 bubble.transform.position = new Vector3(bubble.transform.position.x, bubble.transform.position.y, bubble.transform.position.z - (movement * Time.deltaTime / 50f) );
                 bubble.rigidbody.AddForce(0f,0f,zForce, ForceMode.Force);
             }                
         }
     }
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

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Character Rotation 2 Answers

Animate Character movement? 1 Answer

RTS Camera Rotation and Movement 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