Search Unity

Make a object spawn on player and follow it

Discussion in 'Scripting' started by Moddwyn, Feb 13, 2016.

  1. Moddwyn

    Moddwyn

    Joined:
    Jan 27, 2016
    Posts:
    49


    so in the video, you saw that when i try to pick up the item, it teleports to the players starting pos, but what i wanted to do is, spawn the jetpack on the player and make the jetpack follow the player. code is in the video. i also want if the player is moving, set the jetpacks rotation of y axis to 90 deg. i don't know how to do this, but please help me.
     
  2. Moddwyn

    Moddwyn

    Joined:
    Jan 27, 2016
    Posts:
    49
    someone please?
     
  3. frilanski

    frilanski

    Joined:
    Oct 19, 2013
    Posts:
    11
    not entirely sure how to answer (Probably just me) but if you just make the transform.Translate of your jetpack = to your player in an update function then it should be in the exact same position of your player all the time.
    if you want it to off centre and rotate the jetpack when he is moving then you should be able to check the players trajectory (not sure how but 99% sure possible) and then use if statements to check what direction your player is travelling in and set the translation of your jetpack accordingly.

    hope i helped if not sorry but good luck!;)
     
    Moddwyn likes this.