Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • move an object

    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 462
    Comment on it

    When we are developing games then sometime we need an object which generate from a position and move by itself in a particular direction. So here is the simple code from which yo u can do this.

    You just make your object a prefab and add a script that have this below code written in it. And then instantiate your object at a particular point .

    private Rigidbody rb;
    
    public float speed;
    
    
        void Start () {
            rb = GetComponent<Rigidbody>();
            rb.velocity = transform.forward *speed; // now your object will move in forward direction
        }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: