x


object velocity

Hello all; I wrote these codes to move and object to another with constant velocity according to mouse click. But somethings wrong :S . Help me please :)

var GidecekObje : Transform;
var GidecegiNokta : GameObject;
function Update () 
{

    if (Input.GetMouseButtonDown(0))
    {
        GidecekObje.velocity = 5;
        GidecekObje.transform.position = GidecegiNokta.transform.position;  
    }
}

Thanks for attention...

more ▼

asked Aug 01 '10 at 12:37 PM

user-3865 (google) gravatar image

user-3865 (google)
1 6 6 6

Transform doesn't have a velocity variable. Add a rigidbody to the object and access velocity that way. e.g. gameObject.rigidbody.velocity = Vector3.forward*5;

Aug 01 '10 at 04:30 PM spinaljack
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x318

asked: Aug 01 '10 at 12:37 PM

Seen: 1022 times

Last Updated: Aug 01 '10 at 12:37 PM