Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by SonicScrew12 · May 31, 2016 at 04:03 AM · rotationcolliderobjectrotatecollision detection

Rotating Gameobject not Colliding

When I rotate an object, the object rotates perfectly, but it just passes through anything it collides with.

  function Update(){
       transform.localEulerAngles.y += Input.GetAxis("Mouse X");
       transform.localEulerAngles.x += Input.GetAxis("Mouse Y");
  }

None of the colliders are marked as triggers, and there is nothing else going on. Just two objects next to each other, one rotating and one stationary, the rotating one passing through the stationary one. Any way to prevent this or fix it?

Comment
Add comment · Show 1
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 JedBeryll · May 31, 2016 at 04:57 AM 0
Share

Does the rotating one have a rigid body?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by 5c4r3cr0w · May 31, 2016 at 05:21 AM

First make sure that you have attached rigid body to your game object which you want to rotate.

Second, Don't use transform function because it over writes values of physics engine. By using transform.localEulerAngles you're forcing game object to rotate despite of the colliders. Instead use RigidBody.angularVelocity to Rotate your game object so it will collide with every collider.

So your code would look something like :

     void Update(){
         float Xval = Input.GetAxis("Mouse Y");
         float Yval = Input.GetAxis("Mouse X");
         rb.angularVelocity += new Vector3(Xval , Yval, 0);
     }

Check out this video for more understanding :

https://www.youtube.com/watch?v=ZfjVR-0ZFHU

Comment
Add comment · Show 3 · 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 Owen-Reynolds · May 31, 2016 at 01:19 PM 1
Share

And to rephrase that 2nd paragraph: Unity allows you to move and spin things in an exact perfect way with no interference -- like moving things around yourself in Edit mode. In a script, changing transform.position and rotation does that.

Unity also allows you to "push" objects and let the move and bounce as if they were real -- use the physics system and all physics commands for that.

It works best if you do one of the other, and don't mix them.

avatar image SonicScrew12 · Jun 01, 2016 at 01:22 AM 0
Share

What if I want to have the rigidbody that has "Is $$anonymous$$inematic" enabled? Will it still rotate and stop once it hits the other object?

avatar image 5c4r3cr0w SonicScrew12 · Jun 01, 2016 at 04:35 AM 0
Share

If rigid body is set to $$anonymous$$inematic then any physics functions won't be applied to it. Force , velocity , angular velocity , joints, gravity , all of it won't affect it if is$$anonymous$$inematic is enabled. So it can not be rotated with angular velocity as @Owen Reynolds said you can use one of it and can not mix up both.

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

61 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

Related Questions

Restricting Rotation Of an Object in VR 1 Answer

Object passes through other moving objects 1 Answer

How i can set Start Position and Ending position in ROTATION AROUND AXIS? 0 Answers

Raycast don't rotate with object SOLUTION 0 Answers

How to rotate only Y Axis?? 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