0
\$\begingroup\$

How can I move an object the fastest way?

What I'm trying to do is to make an object pass by at speed that you almost cannot see - like an airplane that moves from side to side in very high speed.

Here is my code:

transform.position = Vector3.MoveTowards(transform.position,
            stopPoint, Time.deltaTime * ms);
\$\endgroup\$
3
  • \$\begingroup\$ The ms parameter there is your speed. Presumably you tried making it very large? How did the results differ from what you want? \$\endgroup\$
    – DMGregory
    May 18 '21 at 23:47
  • \$\begingroup\$ @DMGregory Should I ask my other question again in my other account? I lost the log-in for it and I can't comment on my other question. \$\endgroup\$ May 18 '21 at 23:59
  • \$\begingroup\$ You should follow this guide to merge your accounts and recover access to your old question. You should never re-post a question that has already been asked. \$\endgroup\$
    – DMGregory
    May 19 '21 at 0:06
0
\$\begingroup\$

Yes, Vector3.MoveTowards can be used. All it does - it moves object a bit. The bigger this 'bit' the further it moves.

if you put it in Update() function it will move your object every frame by 'a bit'. The bigger amount it moves the faster it seems to move.

so to adjust the speed in your case just play with values of ms, and stopPoint untill you get effect you are looking for.

Alternative way of moving things is to add rigidbody and give rigidbody a velocity (but not in Update() function).

So these are 2 ways of moving things in Unity - either move bit by bit, or use physics to move it for you (which is also moving bit by bit, but Unity takes care of all details).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .