- Home /
Function Update and error UCE0001
I'm trying to make a simple function that checks for a mouse click on an item and then smoothly translates the camera. I put it in the Update function but if it tells me the inner functions name should be replaced by a ')' and I'm missing a semicolon some where.
function Update () {
//trade scenes
function OnMouseDown () {
var mainCamera = GameObject.Find("Main Camera");
mainCamera.transform.Translate(0,0,10*Time.deltaTime);
}
}
Answer by Eric5h5 · Aug 02, 2013 at 05:32 AM
You can't put functions inside other functions. OnMouseDown works regardless of Update.
Answer by nixcs2512 · Aug 02, 2013 at 05:36 AM
function OnMouseDown can not be placed in Update(), it's a seperate function and will be called right after when a mouse is over object and player click.In your case:
function Update()
{
//something happens in 1 frame
}
function OnMouseDown()
{
//Your code
}
Answer by pranav32100 · Aug 29, 2019 at 01:20 PM
Try this : and see how we have used here function Update () {
//trade scenes function OnMouseDown () { var mainCamera = GameObject.Find("Main Camera"); mainCamera.transform.Translate(0, 180,10*Time.deltaTime); } }