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 NeverGod · Nov 08, 2012 at 10:15 PM · rotationobjectmodelmovingzombie

Model moving from Rotation only?

Hello Unity community, I've run into a very disturbing issue today. I downloaded the Zombie Character pack and a few animations today and I am desperately trying to fix this weird bug. So basically, if you rotate an object in a scene, it should not move (only rotate towards you, duh...) . But when i rotate this Zombie model it starts to move towards the direction its facing with a speed of ~ 0,1/s. I'm sure it has to do something with the rotation and the model itself, because when i comment out the rotation code it does not do it, but the same code does not provoke such a behavior for e.g. a cube.

Another thing is that when i get closer the whole model starts to rotate up to face the main camera, so my second question would be how i can make him rotate only on the x and z axis (note : rigbody fix y rotation does not work for me :S)

Code : Rotation:

 myTransform.rotation = Quaternion.Slerp(myTransform.rotation,Quaternion.LookRotation(target.position - myTransform.position),rotationSpeed * Time.deltaTime);


Additional codes used: Character Controller (standard asset), Root Motion Computer, Normal Character Motor

Note: This does also happen when i disable any animations!

Thanks in advance, if you need any more code or details please ask, i want to get rid of this issue as fast as possible.

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 Seth-Bergman · Nov 08, 2012 at 10:23 PM 0
Share

if the zombie is childed to some other empty parent object, with a different position, that could do this.. make sure the part with the $$anonymous$$eshRenderer is at the top of the hierarchy..

avatar image NeverGod · Nov 08, 2012 at 11:05 PM 0
Share

Although the part with the $$anonymous$$eshRenderer (hips) is Children to zombie_hires they are, as far as i can tell in the same position. I tried to drag that part on top of the hierarchy but that only led to the whole zombie to disappear.

1 Reply

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

Answer by Owen-Reynolds · Nov 08, 2012 at 10:56 PM

This is a new way to get an old problem:

The target rotation is over 3D space. When the camera is far away, you're looking only a little bit up to see it, so not obvious. As you get close, the model is leaning back to do a fully 3D rotate to see you. Fix it by manually making the y values equal, to get a 2D only rotation.

You old code for the target rotation:

 ...  Quaternion.LookRotation(target.position - myTransform.position) ...

Break it up instead, to kill the y (in other words, figure out the "level with you" camera, and look at that):

 Vector3 lookDir = target.position - myTransform.position;
 lookDir.y = 0;
 (in your Slerp):  ... Quaternion.LookRotation(lookDir) ...
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 NeverGod · Nov 09, 2012 at 02:01 PM 0
Share

Thanks that solved everything! Oh the irony, I was so close to solving it myself, ins$$anonymous$$d of setting the y of lookDir to 0 I set it to the player objects y. I don't know why but it seemed logical to me yesterday. Thanks a lot!

avatar image Owen-Reynolds · Nov 09, 2012 at 02:52 PM 0
Share

You weren't wrong. Temp setting target-Y == my-Y is also a solution. The final lookDirection still comes out as zero.

Very common to try something that would have worked, but have some $$anonymous$$or error elsewhere, so you abandon it.

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

11 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

Related Questions

Moving a object around with mouse, rotating it with arrow keys and placing it. 1 Answer

Object problem 1 Answer

Move object A towards object B 2 Answers

2D Sprite/object rotation changing despite telling it not to 0 Answers

Third Person Controller Rotation 0 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