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 /
This question was closed Jan 23, 2018 at 10:54 PM by meat5000 for the following reason:

Ancient and duplicate

avatar image
0
Question by Agent-6141 · Mar 07, 2013 at 03:18 AM · gravitytron

How do I make my object not fly away?

I'm making a tron game and if my bike gets bumped to much it starts flying away. Its like if you were on the moon and you get pushed you fly away. Can anyone help me fix this? Also here is the script that makes my bike constantly go forward, I don't know if it has to do with it.

 var speed:int = 10;
 function Update() 
 {
     transform.Translate(Vector3(0,0,speed) * Time.deltaTime);
 }
Comment
Add comment · Show 3
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 robertbu · Mar 07, 2013 at 05:08 AM 0
Share

A solution for this problem is to use a CharacterController ins$$anonymous$$d of a Rigidbody to interact with the environment.

avatar image meat5000 ♦ · Jan 23, 2018 at 10:54 PM 0
Share

@Sven$$anonymous$$okveldje @LTonon This q is from $$anonymous$$ar 07, 2013 at 03:18 A$$anonymous$$

avatar image flynde · May 22, 2019 at 05:56 AM 0
Share

This is what worked for me: First I Freeze the Rigidbodys Y position and Y rotation. Then in the attached script:

 public float speed = 10;
 public int direction = -1; // depends what direction you want you z axis to go
 
  private void Awake(){
         rb = GetComponent<Rigidbody>();
   }
     private void FixedUpdate(){
         rb.AddForce(0, 0, direction * speed * Time.deltaTime , Force$$anonymous$$ode.Impulse);
     }

2 Replies

  • Sort: 
avatar image
0

Answer by SvenMokveldje · Jan 23, 2018 at 06:15 PM

For the Fly away part you cloud try to make the rigidbody mass higher. This makes sure that there need to be more force to push them away.

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
avatar image
0

Answer by LTonon · Jan 23, 2018 at 08:17 PM

I may be wrong, but I guess that using the transform.Translate() method moves the Game Object without checking for collisions on the next position before actually moving, and then if the bike moves inside another object and it detects a collision, it's going to be pushed away. Try using the velocity attribute of the RigidBody to move the bike, something like this:

 var rb : RigidBody;
 
 function Awake()
 {
     rb = GetComponent.<RigidBody>();
 }

 function Update()
 {
     rb.velocity = new Vector3(0f, 0f, speed * Time.deltaTime);
 }
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

14 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

Related Questions

Ramp for stairs causes player to slide down. 1 Answer

How to enable gravity on gameobject when interact by player 3 Answers

Adding a force(gravity) to a planet. 0 Answers

Why can't I move along the Y axis when I shift gravity from the Y to Z axis? 1 Answer

Character teleports to the apex of full jump height 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