Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Feedback I need my "bullet" gameobject to spawn infront of my player

Discussion in 'Editor & General Support' started by Noriporal, Mar 11, 2024.

  1. Noriporal

    Noriporal

    Joined:
    Sep 14, 2023
    Posts:
    4
    I know that this is a simple line of code, but I just cant remember what it is, I need my gameobject to spawn infront of a different one, but it is just spawning in the player, and it messes things up, here is the code I am currently using and need updated:
    void Update()
    {
    transform.Translate(Vector3.down * speed * Time.deltaTime);
    }
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,495
    Noriporal likes this.
  3. Noriporal

    Noriporal

    Joined:
    Sep 14, 2023
    Posts:
    4
    somewhat, I need the bullet to go in the direction the player is facing, and I also need the bullet to rotate to the player
     
  4. Noriporal

    Noriporal

    Joined:
    Sep 14, 2023
    Posts:
    4
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,033
    You can actually just set the
    transform.forward
    of the bullet equal to the
    transform.forward
    of the player.
     
    Noriporal likes this.
  6. Noriporal

    Noriporal

    Joined:
    Sep 14, 2023
    Posts:
    4
    but how would I do that?
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,033