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!

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 :slight_smile: