the Player object can instantiate Fireball Objects. if I put the code to set velocity in the Start() method, it works as intended. however I want to be able to set speed (and eventually other variables as well) through methods. why is this simple code not working? it instantiates a fireball with no speed.
using UnityEngine;
using System.Collections;
public class Fireball : MonoBehaviour
{
private Rigidbody2D myRigidBody;
void Start ()
{
myRigidBody = GetComponent<Rigidbody2D> ();
}
public void fire (float speed)
{
myRigidBody.velocity = new Vector2 (0, 1) * speed;
}
}