Shooting an arrow

Hi, i made a shooting arrow animation from a tutorial, now it doesnt work really well on placing it at the player object. Which i mean, the animation is going from Z:10 to Z-10. when i put the arrow on the player object, it goes from the base of the player Z to the Z-10, how do i make this dynamic that it only like, fires 10 meters infront of me? And i have a feeling this is done with a script.

The arrow:

Thanks! :smile:

Without any code in scripting forums its hard to tell. I would guess, that your arrow object, where it gets called is not at 0,0,0 inside the player. But just a guess. Give us some more information so we can help.

The arrow is called by this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayAnim : MonoBehaviour {

    public GameObject mainProjectile;
    public ParticleSystem mainParticleSystem;

   
    // Update is called once per frame
    void Update () {
        if (Input.GetKeyUp(KeyCode.F))
        {
            mainProjectile.SetActive(true);
        }

        if (mainParticleSystem.IsAlive() == false)
            mainProjectile.SetActive(false);
    }
}

Its just starting the anim,


Thats bascly all,

Oh, got ya. Your problem is, that your Projectile is not a child of your player. So it is animating it in world space and will start always at -10z. Try to drag the object into your player gameobject.

Thats what i do, and then reset it to 0
But that doesnt really… well, work haha it shoots into the sky then on a random position, not from the player position

Maybe you have to work with Unity - Scripting API: Transform.localPosition instead of position so it is placed at 0,0,0 inside your player and not in world space.