Local Vector3 ?

I need to set my vector 3(wanderPoint) to wander point plus 5 along the local z axis(forward). i tried something like this,

wanderPoint.y = transform.localPosition.y;
wanderPoint.x = transform.localPosition.x;
wanderPoint.z = transform.localPosition.z + speed;

Any ideas?


Thanks

Transform.localPosition is relative to the parent. If there’s no parent, localPostion is the same as position. Use this:

wanderPoint = transform.position + transform.forward * distance;