Object falling through terrain with script

Hi!
First i want to sorry for my english, it’s not my native language.

I have this little script that resizes object ( the player ) from 1.0 to 0.5 on the axis Y.

using UnityEngine;
using System.Collections;

public class Dodge : MonoBehaviour {

	public bool isDodged = false;
	// Use this for initialization
	void Start () {
	      isDodged = false;
	}
	
	// Update is called once per frame
	void Update () {
	     if    ( Input.GetKeyDown(KeyCode.LeftControl)) isDodged = true;
			if ( isDodged == true ) {
			
			   Vector3 scale = transform.localScale;
               scale.y = 0.5f; // This is where it decreases to 0.5
               transform.localScale = scale;
		}
		
		 if    ( Input.GetKeyUp (KeyCode.LeftControl)) isDodged = false;
		    if ( isDodged == false ) {
			
			   Vector3 originalsize = transform.localScale;
			   originalsize.y = 1f;
			   transform.localScale = originalsize;
		}
	}
}

I start with original 1.0 value, when i hold down LeftCTRL the player decreases to 0.5, and after i release the button, it goes back to 1.0
Yes, this works, but when it goes back to size 1.0, it falls through the map.
I think its because it doesn’t has time to calculate colission with map, OR it begins to resize from the center, so a little part remains under the terrain. How could i fix that?

Thank you!

Add this to your script when it resizes:

transform.position.y += 1;

maybe I’m wrong.

You could Raycast downwards to get the position where to place the character right after rise. You would want to shoot it a bit above the player towards -Vector3.up. Then place the character with an offset of 50% of body height (.5f in your case?), if pivot is at center. Think in terms of where the collider is ending up from crouching, rising and standing, it’s usually good to monitor it with the Scene view while playing.