- Home /
Question by
pokeyoshi3 · Aug 13, 2012 at 05:21 PM ·
getcomponentsendmessage
pickup weapon with GetComponent
how to call a function with GetComponent?
example script: weaponprefab
var curWeapon : Transform;
function update()
{
curWeapon.GetComponent(Weaponindexweapon);
if (if Input.GetKeyDown("E"))
{
curWeapon.ChangeShot(blah);
curWeapon.ChangeWeapon(blah);
}
}
example script. Weaponindexweapon
function ChangeShot()
{
blah blah blah
}
function ChangeWeapon()
{
blah blah blah
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613075617im_/https://answers.unity.com/themes/thub/images/avi.jpg)