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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by vantilator · May 22, 2015 at 02:39 PM · rotationquaternionpathfindingastarquaternion.lookrotation

Look rotation makes sudden changes

This is a racing game, I use http://arongranberg.com/astar/ pathfinder for the character runs on a oval racetrack. Player can only play with the characters speed which is calculated and has a high limit. When the player reaches high range of speed character suddenly looks left or right for a moment and straightens back and its very annoying. Its not happening with low speed. What am i missing? The dir vector is calculated same with the astar tutorials. I also use simple smooth modifier.

                dir = (path.vectorPath [currentWaypoint] - transform.position).normalized;
        Vector3 rot = dir;
              rot.y = 0f;
 var targetRotation = Quaternion.LookRotation (rot, Vector3.up);
 transform.rotation = Quaternion.Slerp (transform.rotation, targetRotation, Time.deltaTime * speed * 0.3f);
 
 characterController.SimpleMove (dir * speed * 0.8f);
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 Owen-Reynolds · May 22, 2015 at 03:08 PM 0
Share

Does it only happen near a waypoint (if you have a long, straight section, then a curve, will it only do it when you get to the end)?

Suppose you pass a target to the side. The code makes if always try to look at the target, turning faster as you go faster. So now it's looking sideways to see it, until it turns to see the next one.

avatar image vantilator · May 25, 2015 at 08:46 AM 0
Share

I also tested with long straight section and then a curve; it starts happening from the begining. I also put the target in front of the character and it happens :( I fixed the turning speed and nothing changes.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by vantilator · Jun 01, 2015 at 01:16 PM

I found a solution:

When i checked the angles between dir and transform.position the values are like:

143.7691 143.8332 . . 145.8065 . . 52.40902 (eww!) . . 140.2589

I dont know why my direction vector changes suddenly. Now im checking for sudden angle change and it seems ok, probably not the best solution.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I instantiate a gameobject facing another gameobject 2D? 0 Answers

Turret rotation with a pivot? 1 Answer

How to rotate object to face toward the path using Astar pathfinding? 0 Answers

How to align the transform.rotation.y with the world space vector y? 1 Answer

Rotating an object in relation to its endpoints 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