x


How do I apply drag rigidbody?

I want to click on an object and move it with my mouse. I have a prefab object with a rigidbody & springjoint. I applied dragrigid body script to the prefab in the project view, i get following error:

NullReferenceException: Object reference not set to an instance of an object DragRigidbody.Update () (at Assets\Standard Assets\Scripts\DragRigidbody.js:20)

more ▼

asked Jul 19 '10 at 09:03 PM

R2D2 gravatar image

R2D2
64 6 6 10

apply the script to the camera

Jul 19 '10 at 11:09 PM usman_the_great

first apply the rigidbody from component physics then apply the script to the camera

Jul 19 '10 at 11:11 PM usman_the_great

apply rigidbody to the object you want to drag

Jul 19 '10 at 11:11 PM usman_the_great
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

The DragRigidBody script doesn't go on the RigidBody you want to drag, it goes on a controller script such as First Person Controller. An in-depth explanation can be found here:

http://answers.unity3d.com/questions/4898/drag-gameobject-with-mouse

more ▼

answered Jul 19 '10 at 09:48 PM

Thom Denick gravatar image

Thom Denick
1.9k 13 20 38

(comments are locked)
10|3000 characters needed characters left

apply the rigidbody to the object you want to drag than select your camera and apply the drag rigidbody to the camera use mouse to drag

more ▼

answered Jul 19 '10 at 11:07 PM

usman_the_great gravatar image

usman_the_great
106 4 4 13

(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x1095
x286
x204
x54

asked: Jul 19 '10 at 09:03 PM

Seen: 5200 times

Last Updated: Jul 19 '10 at 09:42 PM