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 /
avatar image
0
Question by barkntuncer · Mar 17, 2021 at 09:37 PM · collisionmovementcubesmoothfriction

The Cube object moves through other cube objects and does not move smoothly on other cube objects,Cube object moves through other cube objects and does not move smoothly

Hi everyone! Currently, I am making some kind of labyrinth game. My main character is a cube object that is moving through the walls which are composed of other cube objects. I do not want this to happen. The character has rigidbody, a box collider, because of this post I changed it to sphere collider later, I freeze the rotation, the object is NOT kinematic and the collision detection is continous. I also move the object with rigidbody.MovePosition. I could not make addforce work when I was using a box collider with frozen rotations. The walls does not have rigidbody. The character can move like a couple of cms inside the walls when you try to move it diagonally. Changing the collider to sphere solved this issue but I do not know why and I would like to learn if there is any other options using box collider. The situation is like this:

alt text

My second problem is that my floor is also made from cube objects stacked together and the character even with the sphere collider cannot move smoothly on it. I created a physics material without any static or dynamic friction and fed it into the floor box collider but it did not work. It stills moves like something is holding it. I do not want my object to float so this is not an option. Also, I do not know why maybe it is because of friction but like I said I do not use addforce, the object keeps moving after I release the key. I would be more than happy if someone could help.

alt text

 public class Movement : MonoBehaviour
 {
     [SerializeField] PlayerManager playerManager;
     [SerializeField] float speed;
 
     public Rigidbody rb;
     public Vector3 movement;
 
  
     void Start()
     {
         rb = this.GetComponent<Rigidbody>();
     }
 
     void Update()
     {
         movement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
         movement.Normalize();
     }
     private void FixedUpdate()
     {
         moveCharacter(movement);
     }
     void moveCharacter(Vector3 direction)
     {
         rb.MovePosition(transform.position + (direction * speed * Time.deltaTime));
         //rb.AddForce(direction * speed);
     }
     private void OnCollisionEnter(Collision collision)
     {
     }
 }


EDIT 1: Apparently, the smoothness problem is not caused by the cube objects. I changed the Fixed Timestep to 0.002 and the issue is solved. Also, for anyone interested the object was sliding when I release the keys. The solution to that was using GetAxisRaw rather than just GetAxis. I would like to know if there is another solution to the so-called smoothness problem without changing the timestep.

fr.png (11.6 kB)
problem.png (19.7 kB)
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

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

218 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 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 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 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 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 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 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 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 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

friction problem 1 Answer

Using WASD keys instead of mouse to roll ball? 1 Answer

How to move a cube constantly with GetKeyDown 3 Answers

Buggy Collision 1 Answer

check if two colliders Rub against each other 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