• 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 voukka · Nov 25, 2012 at 07:11 PM · velocitytransform.position

How do I change direction of moving object?

Hi all!

I'm a beginner in Unity 3D so here's my question:

I have an object moving in 3 dimensional space with constant speed, there's a camera following the object. Camera faces the same direction and moves with the same speed as the object.

Then at some point I need to turn the object and its moving direction by 90 degrees, let's say to the left of the object. The camera must do the same.

What is the (better) way of doing it? I read a bit about local and global spaces. So far I have only used global positions as it felt easier...

Can you please give me some direction on that or even better code sample. Thanks!

Comment
Add comment · Show 1
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 moonLite · Nov 29, 2012 at 02:08 AM 0
Share

can you paste your script too?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by harschell · Nov 29, 2012 at 04:36 AM

Here are some options for you to do this::

1) Include more waypoints and fake a curve. Simple, but awkward.

2) Include a directions to raycast against for corner sections. Assumes you know the structure of your walls, that you have colliders and adds raycasts, making it simple, but costly.

3) Set up a bzier curve or NURBSNon-uniform rational B-spline system for your waypoints. Less simple.

4) You could use iTween which has all of the facilities needed for this. Simple (Look into PutOnPath, PointOnPath, MoveTo with movetopath).

@xvga Hope this helps you out, Do accept it as Answer & Vote it Up if its HelpFull :)

Comment
Add comment · Show 1 · 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 voukka · Dec 01, 2012 at 03:54 PM 0
Share

@harschell thank you for your answer! Could you please provide some sample code as an example of the solution? I'd strongly appreciate that!

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

12 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

Related Questions

Velocity powered rigidbody on a moving platform without parenting. 3 Answers

Resetting Ball Object to the original parent and position 2 Answers

Rigidbody2D.Velocity = Vector2 not changing X Position 1 Answer

Need some help with transform.position and velocity of object. 1 Answer

Two ways to calculate velocity without using Rigidbody, which one is more accurate? 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