dropping a different stone

Hey Folks :slight_smile:

I’ve got a problem. I like to drop a stone ( wich works) and if the player is pressing a certain key (shift) he is supposed to drop a different kind of stone.

Here is my code:

// this script lets the player collect  and drop stones
static var stonecount = 0;
// length of the cast ray
var raydistance : float = 2;
var stone : GameObject;
var stone_freeze : GameObject;

function Update () 
{
Debug.Log(stonecount);

var hit : RaycastHit;

if(Physics.Raycast(transform.position, transform.forward, hit, raydistance))
	{
	// tests if the ray is hitting a stone, if no the player plays a sound, if yes the stone gets collected 
		if(Input.GetButtonDown("Grab_Object"))
		{
		
			if(hit.collider.gameObject.tag =="stone")
				{
					stonecount += 1;
					Destroy(hit.collider.gameObject);
				}
		}
// tests if there is an object in the way when the player puts down the stone
		if(Input.GetButtonDown("Drop_Object"))
			{
			if((hit.collider.gameObject.tag =="stone")  (stonecount > 0))
				{
				audio.Play();
				}
				
			if((hit.collider.gameObject.tag =="level")  (stonecount > 0))
				{
				audio.Play();
				}
				
			}
	}
// if there is no object in the way create/drop a stone
	if(!Physics.Raycast(transform.position, transform.forward, hit, raydistance))
	
	{
		// if the player is pressing the "shift" key create ston A
		if(Input.GetButtonDown("Drop_Object")  (stonecount > 0)  Input.GetButtonDown("Freeze"))
			{
			var thePosition = transform.TransformPoint(new Vector3(0,0,2));
			Instantiate(stone_freeze, thePosition, stone_freeze.transform.rotation);
			stonecount -= 1;
			
			}
		else
			{
			// if not create stone B
				if(Input.GetButtonDown("Drop_Object")  (stonecount > 0))
					{
						var thePosition2 = transform.TransformPoint(new Vector3(0,0,2));
						Instantiate(stone, thePosition2, stone.transform.rotation);
						stonecount -= 1;
					}
			
			}
		}


}

I assigned the Objects in the Player-Object … so why on earth the script isn’t dropping the other kind of stone (stone_freeze) when I’m pressing the shift-key ( Input.GetButtonDown(“Freeze”)) ?

Do you have an idea?

Cheers!

Dawnreaver

Nevermind! Found another way to solve my problem :wink: