Hi, Im making a portal clone game and when I shoot my portal gun to place a portal on the wall I want the portal to gradually grow in size and then stop growing when it reaches the desired size. I figured I could do this with a lerp function but the portal does not grow for some reason (just appears small when I place it on the wall). I have no idea what Im doing wrong. Help!
using UnityEngine;
using System.Collections;
public class PortalShoot : MonoBehaviour {
public GameObject leftPortal;
public GameObject rightPortal;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0)) {
ShootPortal(leftPortal);
}
if (Input.GetMouseButtonDown (1)) {
ShootPortal(rightPortal);
}
}
void ShootPortal(GameObject portal){
int x = Screen.width / 2;
int y = Screen.height / 2;
Ray ray = Camera.main.ScreenPointToRay (new Vector3 (x, y));
RaycastHit hit;
if(Physics.Raycast(ray, out hit) && hit.collider.tag != "Portal" && hit.collider.tag == "Wall"){
portal.transform.position = hit.point;
portal.transform.rotation = Quaternion.LookRotation(hit.normal);
portal.transform.localScale = Vector3.Lerp(new Vector3(0.1f,0.1f,0.1f), new Vector3(2.5f,3.5f,0.01f), Time.deltaTime * 0.5f);
}
}
}