x


How to make my torch move with my player?

Hey people Ive got my character and I have attached my spotlight tomy character, my problem is that as soon as I put the script in : Standard Asseys> Scripts> MouseLook and play the game, my torch moves fasterthan my player.

If I move my mouse 1 cm my person moves 1cm but my torch moves 5cm. If i move my person 2cm my torch flies 10cm away. Can somebody please tell me how to script this. And also I want my person to pick up a knife from the floor, how would he do it?

more ▼

asked Aug 28 '12 at 11:46 AM

armin007 gravatar image

armin007
24 1 4

Is it 3D or 2D? (models or sprites?) If you got models - I think the easiest way will be put some prefab and fix it on the place that you want you're knife/torch (in the Scene view) - then drag it into your Player (in Hierarchy view). Next you must just find how to switch what it contains.

Aug 28 '12 at 12:03 PM McDardy
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Are you trying to move the torch by script? You should instead just child the torch to your camera (if it's a 1st person character), and let Unity do the job for you: when the parent moves or rotates, its children automatically follow it.
Picking up items in the scene usually is a fake operation: the item is just a model with a trigger volume - when the player enters the trigger, the object is destroyed and the player script sets some boolean variable that says it has got the item - take a look at this question

more ▼

answered Aug 28 '12 at 11:58 AM

aldonaletto gravatar image

aldonaletto
41.5k 16 42 197

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

Perhaps if it's getting picked up it can either be (1) destroyed in the scene and then instantiated as a child of the hand, or (2) added as a joint component to the hand. Joints are discussed here. Instantiations are discussed here.

more ▼

answered Aug 28 '12 at 01:41 PM

justinpatterson gravatar image

justinpatterson
40 1 3 5

(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:

x3740

asked: Aug 28 '12 at 11:46 AM

Seen: 261 times

Last Updated: Aug 28 '12 at 01:41 PM