So i am trying to make simple PingPong 2D, the ball is instantiate when you click “Fire1” and I want to make trail effect with spawnings another balls that are animated to fade out and i want same position as instantiate ball but it is spawning all the time at (0,0,0). I chceked transform.position by Debug.Log and it’s good, and show the current position that’s why i have no clue what to do
The code :
public class TrailBall : MonoBehaviour
{
public GameObject ballPrefabTrail;
public float spawnDuration = 1f;
private float spawnDurationCountdown = 0f;
void Update()
{
if (spawnDurationCountdown <= 0)
{
GameObject instance = Instantiate(ballPrefabTrail, transform.position, transform.rotation) as GameObject;
Debug.Log(transform.position);
Destroy(instance, 3f);
spawnDurationCountdown = spawnDuration;
}
else
{
spawnDurationCountdown -= Time.deltaTime;
}
}
}