I have an object that is instantiated by the player, using the players transform and rotation. I am wanting it to wait for a few seconds and then copy the movement of the player with the caveat that if the player hits a wall then the instantiated gameObject can no longer move. I have tried creating it as a child and I have tried to get the Players movement but it I can never get it to stop when the Player is forced to a stop, the gameObject keeps moving.
Here is the code I have so far, but I feel it is not even close to what I am looking for.
function Update ()
{
var mirrorObject = GameObject.Find ("PlayerObject");
mirrorObject = transform;
var controller : CharacterController = GetComponent(CharacterController);
var newPosition : Vector3;
newPosition = transform.TransformDirection (mirrorObject); // Get the mirrorObject's position
if (mirrorX)
{
newPosition.x = -newPosition.x; //Mirror on the X axis
}
if (mirrorY)
{
newPosition.y = -newPosition.y; //Mirror on the Y axis
}
if (mirrorZ)
{
newPosition.z = -newPosition.z; //Mirror on the Z axis
}
controller.Move (newPosition * Time.deltaTime * speed );
}
Can someone lead me down the right track? I don’t mind doing the homework, but I just am hitting my head against the wall.