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?

A problem of scale? Or relative positioning? Without more data about your problem I can’t help much.

Mouselook is not intended to make anything move, but to change the rotation of the camera. So please explain what are your intentions with this script.

Make the torch object child of the person. Just drag the torch with the mouse on the person object and release the mouse. Furthermore remove any references to the torch in the scripts (with respect to movement) (if any).

Effect will be that the torch will stay in the same position relativley to the person, and if the person moves, the torch will follow exactly.

I can give you a simple pick up script

var attachPoint: GameObject;
static var currentObj: GameObject;
    
function Start () 
{
		//First held object
		currentObj = GameObject.Find("RightGun");
	
}

 function OnTriggerEnter (hit : Collider)
 {
 	if(hit.gameObject.tag == "gunS")
 	{
 		Destroy(hit.gameObject.collider);
 		activate(hit.gameObject.name);
                hit.gameObject.transform.parent = transform;
 			  hit.gameObject.transform.localPosition = Vector3(0.0008774202,1.46058,0.7104473);
 			hit.gameObject.transform.localScale = Vector3(0.0008774202,0.0008774202,0.0008774202);
 			hit.gameObject.transform.localEulerAngles = Vector3(0,0,0);
  }
	Destroy(currentObj);
 	currentObj = hit.gameObject;

//sry about the formatting I just copy and pasted the //needed bits from my full code. the full code is here for reference.

var attachPoint: GameObject;
static var currentObj: GameObject;
var PickUpGun : AudioClip;
var PickUpKey : AudioClip;
var Bossfight : AudioClip;
var CSBossfight : GameObject;
var Key1 : GameObject;
var Key2 : GameObject;
var Key3 : GameObject;
var Background : AudioClip;
var LowHealth : AudioClip;
var BossFight : AudioClip;
var Victory : AudioClip;

var guns : GameObject[];



function Start () 
{
		//First held object
		currentObj = GameObject.Find("RightGun");
		audio.loop = true;
		audio.PlayOneShot(Background, 0.1);
		
}
			
 function OnTriggerEnter (hit : Collider)
 {
 	if(hit.gameObject.tag == "gunS")
 	{
 		Destroy(hit.gameObject.collider);
 		activate(hit.gameObject.name);
 		
 		var thisSink = hit.transform;
 		
 		if(hit.gameObject.name == "assultRifle")
 		{
 			
 			audio.PlayOneShot(PickUpGun);
 			
 		 	for (var child : Transform in thisSink)
 		 	{
    			child.gameObject.layer = 8;
			}
 		 	
 			spinGuns.machineGunSpinSpeed = 0;
 			hit.gameObject.transform.parent = transform;
 			hit.gameObject.transform.localPosition = Vector3(0.0008774202,1.46058,0.7104473);
 			hit.gameObject.transform.localScale = Vector3(0.0008774202,0.0008774202,0.0008774202);
 			hit.gameObject.transform.localEulerAngles = Vector3(0,0,0);
  		}
 		else if(hit.gameObject.name == "BFG")
 		{
 		 	audio.PlayOneShot(PickUpGun);
 		 	hit.gameObject.layer = 8;
 		 	
 		 	for (var child : Transform in thisSink) 
 		 	{
    			child.gameObject.layer = 8;
			}
 			spinGuns1.machineGunSpinSpeed1 = 0;
 			hit.gameObject.transform.parent = transform;
 			hit.gameObject.transform.localPosition = Vector3(0.006829367,1.341706,0.7675902);
 			hit.gameObject.transform.localScale = Vector3(0.0008135902,0.0008135902,0.0008135902);
 			hit.gameObject.transform.localEulerAngles = Vector3(0,0,0);
 		 }
 		/*
 		if((currentObj.name == "assultRifle") || (currentObj.name == "BFG"))
 		{
 			currentObj.renderer.enabled = false;
 		}
		if(currentObj.name == "RightGun")
 		{
 			transform.position.y -= 100;
 		}
 		*/
 		
 		
 		Destroy(currentObj);
 		currentObj = hit.gameObject;
	}
	if(hit.gameObject.tag == "keY")
 		{
 		if(hit.gameObject.name == "Key1")
 		{
 		Destroy(hit.gameObject.collider);
 		//add stuff here
 		audio.PlayOneShot(PickUpKey);
 		Destroy(Key1);
 		}
 	if(hit.gameObject.name == "Key2")
 		{
 		Destroy(hit.gameObject.collider);
 		//add stuff here
 		audio.PlayOneShot(PickUpKey);
 		Destroy(Key2);
 		} 
 	}
 	if(hit.gameObject.tag == "ChangeMusic")
 	{
 		//audio.Stop();
 			if(hit.gameObject.name == "bossFightDoor")
 			{
 				FadeInBossFight();
 				FadeOutBackground();
 				//audio.PlayOneShot(Bossfight, 0.3);
 				Destroy(hit.gameObject.collider);
 				Destroy(CSBossfight);
 			}
 	}
 }


function FadeInBossFight() 
{
	audio.PlayOneShot(Bossfight, (0.1 * Time.deltaTime));
    //audio.volume(BossFight) += 0.1 * Time.deltaTime;
}

function FadeOutBackground() 
{
	audio.PlayOneShot(Bossfight, (-0.1 * Time.deltaTime));
    //audio.volume(Background) -= 0.1 * Time.deltaTime;
}





function activate(gName : String){
	for (var i = 0; i < guns.Length; i++){
		guns*.SetActiveRecursively(false);*
  • }*

  • if (gName == “RightGun”)*

  • {*

  •  guns[0].SetActiveRecursively(true);*
    
  • }*

  • else if (gName == “assultRifle”)*

  • {*

  •  guns[1].SetActiveRecursively(true);*
    
  • }*

  • else if (gName == “BFG”)*

  • {*

  •  guns[2].SetActiveRecursively(true);*
    
  • }*
    }