TransformDirection using original transform

I'm working on a simple script that will create an object a couple meters in front of the character. For now I've been using a default sphere. I tried to do it using transform.TransformDirection, but it seems to always use the character's original position for the transform. No matter where the character moves, the sphere is always created in relation to where the character started at the beginning of the level, instead of where it is at the moment. Let me know if I'm missing anything.

Here's the code:

using UnityEngine; using System.Collections;

public class spawnPrefab: MonoBehaviour {

public Transform sphere;
float lastCast = -10f;
float castTime = .5f;
void Start () {


void Update () {
        if(Time.time - lastCast > castTime){
            lastCast = Time.time;

void spawn(){
    Transform currentPos = transform;
    float currentY = transform.position.y;
    Vector3 newPos = currentPos.TransformDirection(
    newPos.y = currentY;
    Instantiate(sphere, newPos, transform.rotation);        


Your code rotates the vector (0, 0, 3) according to the player's rotation, but the player's position is not considered at all. So, newPos will always be some vector (approximately) 3 units away from the origin.

Since it looks like you want to treat the input value as a point in this case, you'll probably want to use TransformPoint() instead.