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
2
Question by Darwin Mecharov · Apr 05, 2014 at 06:45 AM · collisionmovementcollidertransform.translateshake

Player shaking when colliding with objects

Hi! I've recently encountered a problem with my player GameObject's script. As the question says, my object is shaking everytime it moves towards any object. Is there some way I can stop it from doing so? Here is my script:

var MoveSpeed : float = 2.5f;

var RunSpeed : float = 5f;

var Forward : float = 3.5f;

var JumpHeight : float = 10000f;

var Jumped = false;

 function Start ()
 {
     rigidbody.freezeRotation = true;
 }
 function Update ()
 {
     if(Input.GetKey(KeyCode.Space) && !Jumped)
     {
         Jumped = true;
         rigidbody.AddForce(Vector3.up * JumpHeight *  Time.deltaTime);
     }
     //Player movement
     if(Input.GetKey(KeyCode.W))
         transform.Translate(Vector3.forward * Forward * Time.deltaTime);
     if(Input.GetKey(KeyCode.S))
         transform.Translate(Vector3.back * MoveSpeed * Time.deltaTime);
     if(Input.GetKey(KeyCode.D))
         transform.Translate(Vector3.right * MoveSpeed * Time.deltaTime);
     if(Input.GetKey(KeyCode.A))
         transform.Translate(Vector3.left * MoveSpeed * Time.deltaTime);
     //Player run movement
     if(Input.GetKey(KeyCode.LeftShift))
     {
         if(Input.GetKey(KeyCode.W))
             transform.Translate(Vector3.forward * Forward * Time.deltaTime);
         if(Input.GetKey(KeyCode.S))
             transform.Translate(Vector3.back * MoveSpeed * Time.deltaTime);
         if(Input.GetKey(KeyCode.D))
             transform.Translate(Vector3.right * MoveSpeed * Time.deltaTime);
         if(Input.GetKey(KeyCode.A))
             transform.Translate(Vector3.left * MoveSpeed * Time.deltaTime);
     }
 }
 function OnTriggerStay ()
 {
     Jumped = false;
 }

That's all! I don't know if its because I'm using Translate. Sorry, I've only started Unity about a week ago.

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 Darwin Mecharov · Apr 05, 2014 at 05:28 PM 0
Share

Ahh! Thank you so much! It's all fixed now! (If only I could turn your comment into the answer!)

avatar image Dave-Hampson ♦♦ · Apr 09, 2014 at 11:49 AM 0
Share

I've converted the comment into an answer and marked it as correct for you.

avatar image Darwin Mecharov · Apr 10, 2014 at 04:13 PM 0
Share

Oh thank you

3 Replies

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

Answer by KingDolphin · Apr 05, 2014 at 08:12 AM

It is because of transform.translate, what transform.translate does it literally move the object a certain amount, which really messes up colliders, believe me it messed me up for a long time. For a good supplement, I started using rigidbody.velocity, like this rigidbody.velocity = transform.forward Forward Time.deltaTime; It doesn't give the exact same effect, and to stop the sliding I messed around with Drag a bit in rigid body, hope this helps

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 wanderswaffles · May 08, 2021 at 07:32 PM

aaaaaaaaaaaaaaaaam WtF_

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 FrozenTrident · May 09, 2021 at 04:13 AM

The only Problem with Rb.velocity has a sliding effect and if you want a similar movement to translate.transform use Rb.MovePosition in the fixed update that way it will interact with the colliders and stop the sliding and you wont need to mess around with the drag which has side effects and cause you to jump weirdly;

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

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

Related Questions

Transforming position for different colliders for repeating background? 0 Answers

Colide objects with runtime gizmo movement 0 Answers

Object collider not operating properly 2 Answers

Stopping my player from moving when hitting a wall. 5 Answers

Sinking Sand 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