While trying to create a script that resets the player’s position if they are to clip through the floor, I ran into an issue where the function “Collider.ClosestPointOnBounds()” was not accepting the assignment of the position parameter, which takes a datatype of Vector3, to transform.position. The error returned was “CS0029: Cannot implicitly convert type ‘UnityEngine.Vector3’ to ‘UnityEngine.Transform’”. How do I fix this?
private void ResetPlayerPos()
{
Vector3 playerPos = transform.position;
if (Physics.CheckBox(overlapPos, playerSize, playerTransform.rotation, 3))
{
collisions[0] = Physics.OverlapBox(overlapPos, playerSize, playerTransform.rotation, 3)[0];
playerTransform = playerCollider.ClosestPointOnBounds(position: playerPos);
}
}