Pickup instantiates from a projectile, but not where it is supposed to instantiate.
So I'm making a third person shooter for a school project, and there is a twist where you shoot darts, and the darts are shot and turn into pickups after a short amount of time. I have this set to a timer, and if the timer reaches a certain number, it runs this function:
void SpawnPickup() { Instantiate(pickup, transform.position, transform.rotation); pickup.GetComponent().velocity = transform.TransformDirection(Vector3.forward * 10); Destroy(gameObject); }
The problem is, when the pickup spawns, it does not instantiate with the transform.position of the projectile, it spawns behind, above, and to the left of where the dart was. I tried printing the position of the pickup after it was instantiated, but each pickup, no matter where it was, printed
-2.5, -0.9, 2.4
for its position. I have no idea why this is happening, so I'm up for any ideas. Thanks for the help!