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 Heffalus · May 11, 2015 at 08:32 PM · c#rotationsphereeulerangles

object placement on sphere, rotation deform

So i have a Tower Defense game that im making, and im attaching my towers to a sphere wich is the game level. But the tower is deformed when an enemy comes in range and it rotates towards it.

 void Update ()
     {
 
         if (target) {
             aim_pan.LookAt (target);
             aim_pan.eulerAngles = new Vector3 (0, aim_pan.localEulerAngles.y, 0);
             aim_tilt.LookAt (target);
 
             pivot_pan.rotation = Quaternion.Lerp (pivot_pan.rotation, aim_pan.rotation, Time.deltaTime * turnSpeed);
             pivot_tilt.rotation = Quaternion.Lerp (pivot_tilt.rotation, aim_tilt.rotation, Time.deltaTime * turnSpeed);
 
             if (Time.time >= nextFireTime) {
                 FireProjectile ();
             }
         }
     
     }

this is what rotates the tower, when i first place it its rotation is correct. aim_pan and aim_tilt are child objects. The base that rotates arount the y and the top that tilts up and down

     GameObject newStructure = Instantiate (allStructures [structureIndex], 
 lastHitObject.transform.position, lastHitObject.transform.parent.rotation) as GameObject;

this is the instantiation of the tower, lastHitObject is a child plane to the sphere world. its rotated correctly aswell.

Comment
Add comment · Show 2
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 FortisVenaliter · May 11, 2015 at 09:08 PM 1
Share

Not sure that I understand 100%, but here's a few things to try:

On the LookAt functions, specify the second parameter "up" to be the sphere's normal at that position.

Ins$$anonymous$$d of using transform.rotation, try using transform.localRotation.

avatar image Heffalus · May 12, 2015 at 11:03 AM 0
Share

I figured it out it was th aim_pan.eulerAngles, changed it to localEulerAngles.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AntonyBaasan · May 12, 2015 at 09:49 AM

Usually deformation happens, if you put too big number after decimal point in scale parameter of a parent Transform.

For example:

  • Bad scale x=3.44345454, y=5.454353453, z=4.3240003

  • Good scale x=3.44, y=5.45, z=4.32

Good luck.

Comment
Add comment · Show 2 · 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 xortrox · May 12, 2015 at 10:41 AM 0
Share

depending on the towers structure it could be that the parent object has a bizarre scale like Vector3(1,3,1) or similar so that when the child objects get rotated they scale with the parent and thus end up deformed as well.

avatar image Heffalus · May 12, 2015 at 11:03 AM 0
Share

It was some local rotations, but thanks for the info. i didnt know this, will be $$anonymous$$dfull of scales :)

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

20 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

Related Questions

Flip over an object (smooth transition) 3 Answers

RotateAround reversing doesn't work with negative vector3 0 Answers

Third person follow camera on a sphere 1 Answer

Rotating Sphere With Mouse 2 Answers

Camera rotation behaving strangely 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