I wish to assign a game object based on collision, i was essentially creating a empty object and assigning it to the variable then changing at run time but im assuming that you shouldnt need to do that.The basics of it is, you start off with no items inyour hand, you will have to pick one up . so when you collidee with an item you should then be able to pick it up and this assign the selectedTool to the gameObject in question
void OnCollisionStay(Collision Other)
{
startTime +=Time.deltaTime;
if(startTime >5.0f){
if(Other.collider.tag==("Pickable"))//change mayybe to pickable
{
if(Other.collider.gameObject.name =="Scalpal")
{
tools.selectedTool=0;
}
else if(Other.collider.gameObject.name=="scissors")
{
tools.selectedTool=1;
}
else{
tools.selectedTool=2;
}
bool isEquipped = CheckTools();//if true then something has been picked up
selectedTool = Other.collider.gameObject;
Debug.Log(selectedTool);
if(lastSelectedTool != null){//so if there was a tool which was last selected
lastSelectedTool.GetComponent<SelectableUtils>().unselect();//unselect it and give a new value
lastSelectedTool = selectedTool;
selectedTool.GetComponent<SelectableUtils>().select(isEquipped);
}
so at selected = other.colider.gameObject i get an error at runtime saying that the game object is not yet assigned when i actually collide with one of the items.