hi i want a script attach to all guns objects but only work for 1 object !
#pragma strict
// attach to guns
var aimplace : Transform ;
var gunplace : Transform ;
public var smooth : float = 1.0 ;
var pickup : boolean = false ;
var script : DelayEffect; // Active Dealy effect script
var myColliders: BoxCollider[] ;
public var playerhands : GameObject ; // player attach to this
// for hands
public var weightForLHPosition : float;
public var weighForLHRotation : float;
public var weighforRHPostion : float;
public var weighforRHRotation : float;
// drop sound
@script RequireComponent(AudioSource)
public var drop : AudioClip;
// for siwch weapons
/*private var currentWeapon : int;
private var slot1 : GameObject;
private var slot2 : GameObject;
private var slot3 : GameObject;*/
function Start () {
script = GetComponent(DelayEffect);
script.enabled = false;
}
function Update ()
{
//for siwch weapon
//for pickup
if(pickup == true)
{
playerhands.GetComponentInChildren(PlayerControl).weightForLHPosition = weightForLHPosition =1;
playerhands.GetComponentInChildren(PlayerControl).weighForLHRotation = weighForLHRotation =1;
playerhands.GetComponentInChildren(PlayerControl).weighforRHPostion = weighforRHPostion =1;
playerhands.GetComponentInChildren(PlayerControl).weighforRHRotation = weighforRHRotation = 0;
if(Input.GetMouseButton(1))
{
this.transform.position = Vector3.Lerp(transform.position, aimplace.position, Time.deltaTime * smooth);
this.transform.rotation = Quaternion.Lerp(transform.rotation, aimplace.rotation,Time.deltaTime * smooth);
}
else
{
//this.transform.position = gunplace.transform.position;
//this.transform.rotation = gunplace.transform.rotation;
this.transform.position = Vector3.Lerp(transform.position, gunplace.position, Time.deltaTime * smooth);
this.transform.rotation = Quaternion.Lerp(transform.rotation, gunplace.rotation, Time.deltaTime * smooth);
}
}
else
{
playerhands.GetComponentInChildren(PlayerControl).weightForLHPosition = weightForLHPosition =0;
playerhands.GetComponentInChildren(PlayerControl).weighForLHRotation = weighForLHRotation =0;
playerhands.GetComponentInChildren(PlayerControl).weighforRHPostion = weighforRHPostion =0;
playerhands.GetComponentInChildren(PlayerControl).weighforRHRotation = weighforRHRotation = 0;
}
Part of my code does not work
if(pickup == true)
{
playerhands.GetComponentInChildren(PlayerControl).weightForLHPosition = weightForLHPosition =1;
playerhands.GetComponentInChildren(PlayerControl).weighForLHRotation = weighForLHRotation =1;
playerhands.GetComponentInChildren(PlayerControl).weighforRHPostion = weighforRHPostion =1;
playerhands.GetComponentInChildren(PlayerControl).weighforRHRotation = weighforRHRotation = 0;
why ? how can i fix it ?