c# - Unity How to make GameObject Speed gain velocity -


i have torpedo in unity3d game i'm making in unity3d , have torpedo fire out of sub. how can make torpedo fire torpedo (start slow) , gain lots of momentum , speed up, in movies.

below code how i'm doing this, doesn't work well.

    float torpedospeed = (0.00001f) * 155.2f;     //move     gameobject.transform.position += new vector3(velocity, 0, 0) * 15.5f; 

modern torpedo can speed because propelled. therefore trick accelerate torpedo.

acceleration requires force in direction. must first determine mass of torpedo, allow apply force accelerates.

enter image description here

so acceleration force applied divided mass of object.


that being said, can add force object in unity using:

gameobject.rigidbody.mass = 0.5;  gameobject.rigidbody.addforce(100, 0, 0); 

or can add constant force keep torpedo accelerating.

gameobject.constantforce.relativeforce = vector3(0, 0, 1); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -