heya guys,
So I know that this has been posted many times. But I couldn’t really understand using the ‘getcomponent’ etc.
I want to use a variable called ‘aantal’ to make you only pick up one weapon.
The script I’ve made so far:
#pragma strict
var scimitaroppakken : boolean;
public var aantal : int;
function OnTriggerEnter (other : Collider)
{
if(other.tag == "Player")
{
scimitaroppakken = true;
}
}
function OnTriggerExit (other : Collider)
{
if(other.tag == "Player")
{
scimitaroppakken = false;
}
}
function Update ()
{
if(scimitaroppakken == true)
{
if(Input.GetMouseButton(0))
{
if(aantal < 1)
{
gameObject.active = false;
aantal = aantal + 1;
}
}
}
}
and script 2:
#pragma strict
var zwaardoppakken : boolean;
public var aantal : int;
function OnTriggerEnter (other : Collider)
{
if(other.tag == "Player")
{
zwaardoppakken = true;
}
}
function OnTriggerExit (other : Collider)
{
if(other.tag == "Player")
{
zwaardoppakken = false;
}
}
function Update ()
{
if(zwaardoppakken == true)
{
if(Input.GetMouseButton(0))
{
if(aantal < 1)
{
gameObject.active = false;
aantal = aantal + 1;
}
}
}
}
I dont understand why the public var aantal is not working on the other script