• 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 GC1983 · Jan 23, 2013 at 05:42 AM · simplepath

SimplePath Pathfinding LookRotation

I understand this isnt much of a general Unity question and would be more of a question to ask Alex, but I thought maybe anyone here could possibly answer faster. Alex hasnt answered his forum in over a week...

I have LookRotation() for my pathfinding object which works nicely until i set the nodes at an angle to one another. I set up 6 path nodes in a large arc. when the object reaches each node, its facing direction quickly snaps upward and then continues to the next node. Its very quick, but the object looks like its jerking on each node. Is there a better way of facing the object forward in its moving direction and keep it from jerking upward at each node?...just make it look more fluid through its path.

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 cdrandin · Jan 23, 2013 at 05:57 AM 0
Share

If it jerks up like crazy, why not force the y position of the camera to be the same as the node's y position. Thus haven't it move at the same height while waiting for look at the next node.

avatar image GC1983 · Jan 23, 2013 at 06:26 AM 0
Share

How exactly would I do that?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by cdrandin · Jan 23, 2013 at 06:33 AM

I took this from the docs provided by unity.

 var target : Transform;
 function Update () {
     var relativePos = target.position - transform.position;
     var rotation = Quaternion.LookRotation(relativePos);
     transform.rotation = rotation;
     transform.eulerAngles = Vector3(transform.eulerAngles.x, GameObject.Find("some node").GetComponent(Transform).rotation.y, transform.eulerAngles.z);
 }


Something like this would work. Which hopefully gets the same position from the LookRotation, but instead restricts the rotation to be the same as the node. Not sure this will work at all, but the idea is there. What you want is to get the appropriate angle you want and set it to your camera so that it doesn't jerk. Another alternative could be to quickly use LookRotation on the next node quickly so it never gets to the point of jerking up.

Put it in answers, because the comment format for code is horrid.

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 cdrandin · Jan 23, 2013 at 06:36 AM 0
Share

If this doesn't work, you need someway to fix the right angle for the Y position which makes it move up and down. SO restricting that is key. If you want you can just set it to 90.0 or 0 which is just looking forward, angle depends on the pivot of your camera.

avatar image GC1983 · Jan 25, 2013 at 08:19 AM 0
Share

I appreciate your help. I just decided not to make it so complicated and put them at straight angles. $$anonymous$$uch cleaner look. Thanks anyway.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

SimplePath instantiated AI 2 Answers

how to make a gameobject(Actor_Patrol),Stop And Wait,in SimplePath. 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