Search Unity

Instantiating New prefab to have same velocity as Existing prefab

Discussion in '2D' started by OddSocks_Studios, Oct 21, 2019.

  1. OddSocks_Studios

    OddSocks_Studios

    Joined:
    Aug 26, 2019
    Posts:
    2
    Hi guys.
    I'm going wrong somewhere in my code for a Unity 2D game.
    I'm spawning a missile to have the same speed as a different version of it, currently it just spawns and sits flat on the ground. both have a bounce texture and the first missile is told to delete itelf and spawn a new missile prefab upon collision with ground in the same place, this works - adding the movement values, does not?
    Thanks!
    Nick

    void playFlash()
    {
    GameObject playFlash = (GameObject)Instantiate(Flash);
    playFlash.transform.position = transform.position;
    playFlash.transform.rotation = transform.rotation;
    playFlash.GetComponent<Rigidbody2D>().velocity;
    }