Question by
Darthmaydar · Sep 30, 2015 at 05:42 PM ·
physicsplayeraxis
How can I drop an object from my player object with getmousebuttondown??
I am trying to make a mini game within my main game where you fly around as a bird and drop poop lol. I have already programmed a decent flying script, and have a prefab for the poop. I cannot figure out how to make the prefab drop from the character with getmousebuttondown. Can anyone help me with a script??
Comment
Best Answer
Answer by Jessespike · Sep 30, 2015 at 05:55 PM
In your bird script:
public GameObject pooPrefab;
void Update () {
if (Input.GetMouseButtonDown(0))
{
Instantiate(pooPrefab, this.transform.position, Quaternion.identity);
}
}
In your poo script:
public float fallSpeed = 1f;
void Update() {
transform.position = new Vector3(transform.position.x,
transform.position.y - (fallSpeed * Time.deltaTime),
transform.position.z);
}
thank you so much i couldnt figure out what to put in the y axis im a novice at scripting. Works prefectly!!!!!!