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 TwiningLion1357 · Jul 18, 2020 at 12:15 AM · rotationy-axisy axisstretching

Gun stretches when rotated

Does anyone know why this is happening?

normal:

alt text

rotated:

alt text

screenshot-2.png (250.6 kB)
screenshot-3.png (262.0 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

3 Replies

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

Answer by Eno-Khaon · Jul 18, 2020 at 06:57 PM

This stretching occurs as the result of a parent Transform's non-uniform scale being applied to a child Transform. This becomes especially visible during rotation, when that 3-axis scale attempts to apply itself to a child Transform at any, but especially at any non-90-degree rotations.

A simple solution to this is to ensure that a GameObject's parent Transform has a uniform scale Vector3.one * scale (for example, by putting both parent and child objects into a separate, unscaled container instead).


Since I couldn't get images to upload in a comment, I edited this answer with the intended comment to include the intended images.

Certainly! Here's a step-by-step (from scratch) on what you're seeing, vs. how you can work around it:

1) Create two cubes, then drag one onto the other in the Hierarchy to make it the child object.
2) Scale up the parent object on a single axis. The child will scale along with it. Note at this time that the child's scale is still (1, 1, 1).
3) Rotate the child. It will deform heavily during the rotation, since it's being stretched along a fixed axis by its parent.
4) To deal with this: Create an Empty GameObject. This will act as the new "parent" to the child instead. When you drag it onto the Parent Cube to make it a child, Unity will automatically calculate the inverse scale to ensure that its scale becomes (1, 1, 1), relative to its parents. Additionally, ensure that it has no rotation relative to the Parent Cube (otherwise, you will see distortion again).
5) Rotate the Child Cube again. This time, it will behave as you intend for it to.

alt text
alt text

example123.png (84.9 kB)
example45.png (42.2 kB)
Comment
Add comment · Show 6 · 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 TwiningLion1357 · Jul 18, 2020 at 08:50 PM 0
Share

Thank you @$$anonymous$$o-Khaon for your response. I am kind of new to unity, so is there a way to explain it step by step so I can follow along?

avatar image Eno-Khaon TwiningLion1357 · Jul 19, 2020 at 12:45 AM 0
Share

Of course! I edited my answer to include a more detailed breakdown of how to replicate both the intended and unintended outcomes.

avatar image TwiningLion1357 Eno-Khaon · Jul 19, 2020 at 04:06 AM 0
Share

Update: I fixed the stretching, but I don't know if I set it up like you explained. Here is a screenshot of what is happening:alt text

screenshot-7.png (266.3 kB)
Show more comments
avatar image
0

Answer by tuinal · Jul 18, 2020 at 12:29 AM

All objects have a pivot (origin) around which they scale and rotate. If this is not in the point you want it to rotate around, you'll get this kind of behaviour.

This is set in the modelling software rather than unity. If you're using Blender, select a vertex on the grip in edit mode > shift S cursor to selection > object mode > object > set origin > origin to 3D cursor.

Comment
Add comment · Show 5 · 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 TwiningLion1357 · Jul 18, 2020 at 04:27 PM 0
Share

@tuinal, thank you for your time, but that didn't seem to help the problem. I followed your steps word by word, and it just didn't seem to work.

avatar image tuinal TwiningLion1357 · Jul 18, 2020 at 04:34 PM 0
Share

It it's editor rotation, you have 'centre' on at the top of the screen (next to global), this needs changing to 'pivot' by clicking on it.

avatar image tuinal TwiningLion1357 · Jul 18, 2020 at 04:37 PM 0
Share

nb the pivot point in blender is shown as a yellow dot in object mode - you want it in the middle of the grip - it's easy to accidentally click elsewhere in the steps above which can move the 3d cursor accidentally.

avatar image tuinal TwiningLion1357 · Jul 18, 2020 at 04:39 PM 0
Share

& if none of that works try selecting the object and object > apply > all transforms before the steps above. )

avatar image TwiningLion1357 tuinal · Jul 18, 2020 at 06:48 PM 0
Share

Just tried what you said, that doesn't seem to work either :(

avatar image
0

Answer by RynthGames · Jul 18, 2020 at 11:14 PM

Okay, so first we need to know how you've created your gun. Have you modelled the gun in a separate application such as Blender or 3DS Max, or have you just made it from cylinders using Unity by itself? Judging by the names of the objects, it looks like you've just cobbled together some cylinders in Unity, which is fine but this makes things a little more complex...


So, if you're going to make your gun in Unity, I'd suggest starting with an empty GameObject which you can name "Gun", and then put a couple of cylinders inside of there to represent the grip and barrel. Now the important thing is that you leave the position, rotation, and scale of your "Gun" object at (0,0,0), (0,0,0) and (1,1,1) - this is going to save you a bunch of headaches later on.


With this in mind, adjust the position, rotation, and scale of your cylinders to model your gun - you shouldn't need to mess with the transform of "Gun" to do this. One thing to remember is that you need to position your grip and barrel so that they lie at a suitable point in relation to the origin (0,0,0), as the origin is the point around which your gun will rotate.


Hopefully this will help a little. Just give us a shout if you need any more help (I don't know how new to games development you are, but remember we all have to start somewhere)!

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

173 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

Related Questions

How To Make a 3d object follow mouse and move towards it while the camera is following that 3d object? 1 Answer

Convert Object Rotation to X, Y values 1 Answer

Getting cosinus of an angle in degrees 3 Answers

How can I rotate WheelCollider around local axis? 0 Answers

Limit on x rotation axis in play mode 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