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 Butter_Meister · May 09, 2013 at 05:21 AM · physicsrigidbodycolliderwalls

Player keeps bouncing off the walls

After many attempts at creating walls, I've finally created a player hitbox with rigidbody that collides iwth box colliders. However, instead of just stopping at the walls, they do tiny bounces off of them. Here's the video of it and my basic movement code. Remember this is all just playing around at first, not a serious attempt at a game.

http://youtu.be/m9r9Ug1qvoI

 #pragma strict
 
 public var moveSpeed : float = 10f;
 
 function Update ()
 {
     if(Input.GetKey(KeyCode.UpArrow))
         transform.Translate(Vector3(0, 1, 0) * moveSpeed * Time.deltaTime);
     
     if(Input.GetKey(KeyCode.DownArrow))
         transform.Translate(-Vector3(0, 1, 0) * moveSpeed * Time.deltaTime);
     
     if(Input.GetKey(KeyCode.LeftArrow))
         transform.Translate(-Vector3(1, 0, 0) * moveSpeed * Time.deltaTime);
     
     if(Input.GetKey(KeyCode.RightArrow))
         transform.Translate(Vector3(1, 0, 0) * moveSpeed * Time.deltaTime);
 }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by aaronov · May 09, 2013 at 05:29 AM

Have you tried giving your player and the world a default physics material with a Bounciness value of 0?

Comment
Add comment · Show 8 · 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 Butter_Meister · May 10, 2013 at 02:41 AM 0
Share

And how would I go about doing that?

avatar image aaronov · May 10, 2013 at 02:44 AM 0
Share

Physics $$anonymous$$anager

Physics $$anonymous$$aterial

avatar image Butter_Meister · May 10, 2013 at 02:49 AM 0
Share

I gave both the player and the wall a phsycis material with zero bounciness. The same thing still hapens

avatar image aaronov · May 10, 2013 at 02:53 AM 0
Share

I'm actually surprised your objects are even colliding. As far as I'm aware if you translate a Rigidbody using transform.Translate() you void collision detection and the object would pass through other objects.

You might want to look into Rigidbody.$$anonymous$$ovePosition()

avatar image Butter_Meister · May 10, 2013 at 03:00 AM 0
Share

That just makes the player fly away instantly.

Show more comments
avatar image
0

Answer by sammo · May 10, 2013 at 08:50 AM

try setting the player's rigidbody drag to infinity, this usually fixes similar problems to this i've encountered

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

15 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

Related Questions

Rigidbody (Player) goes through wall 2 Answers

Ignore sub-colliders for center of mass in Rigidbody2d? 1 Answer

Tossing an object with the correct force at any distance from another so that it collides with the other 1 Answer

Importing a wall with doorway into unity, but rigid body/collider is affecting the door way (empty gap) 1 Answer

Enemy Cube going through walls. 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