Added raycasting to terrain for collision detection