Move character to abolute z position

I need to move a character to an exact z position but the same x and y

I tried this

newZPos = 1.5f;

transform.position = new Vector3(transform.position.x, transform.position.y, newZPos)

but all it does is the character falls through the ground and keeps dropping (i.e. the Y changes)

Any ideas??

Sounds like there’s nothing to prevent gravity from taking over in your new Z position. If you don’t want that to happen, you could uncheck the “Use Gravity” option in the object’s Rigidbody component. Or you could make sure there’s some kind of floor under the object that prevents it from falling.