public class Player : MonoBehaviour
{
public Vector2 jumpForce = new Vector2(0, 300);
public GameObject egg;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyUp("space") || Input.GetMouseButtonDown(0))
{
GetComponent<Rigidbody2D>().velocity = Vector2.zero;
GetComponent<Rigidbody2D>().AddForce(jumpForce);
if (Input.GetKeyDown(KeyCode.F))
{
GameObject shot = GameObject.Instantiate(egg, transform.position, transform.rotation) as GameObject;
}
}
}
}
what i am trying to achieve here is i want aa egg to drop directly from inside my player when ever i press a button, i am using an eggprefab to instantiate from inside the player but its not working ,can someone help me or guide to a right tutorial please c#.