- Home /
Zoom in on object and make other objects disappear on zoom?,Zoom in on object and make other objects disappear
Hello! Probably very basic question but am new to Unity so bear with me... Am creating an information app type thing. I currently have five cubes in a row in my scene (these will eventually be replaced with bone models brought over from max), and have worked out how to make each one rotate separately when clicked. HOWEVER I want to zoom in on the cube when I click on it, and make the other, non-clicked cubes disappear when this zoom happens. The clicked cube should also be rotating as the zoom happens. I have trawled the answers pages with no success, and am totally confused as to whether I need to be animating my camera or my cubes... Both?!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoneZoomRotate : MonoBehaviour {
public GameObject target;
public bool rotate = false;
//adapted from https://gamedev.stackexchange.com/questions/95379/rotating-an-object-continously-with-onmousedown
void OnMouseDown()
{
rotate = !rotate;
}
void Update()
{
if(rotate)
{
target.transform.Rotate (new Vector3 (0,15,0) * Time.deltaTime * 5);
}
}
}
^^^ that is my current code that makes each cube rotate when clicked individually; would like to keep the zoom code in that too? If that's possible?
Thanks in advance and sorry for stupid question but am so confused... ,Hello! Probably very basic question but am new to Unity so bear with me... Am creating an information app type thing. I currently have five cubes in my scene (this will eventually be replaced with models brought over from max), and have worked out how to make each one rotate separately when clicked. HOWEVER I want to zoom in on the cube when I click on it, and make the other, non-clicked cubes disappear when this zoom happens. The clicked cube should also be rotating as the zoom happens. I have trawled the answers pages with no success, and am totally confused as to whether I need to be animating my camera or my cubes... Both?!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoneZoomRotate : MonoBehaviour {
public GameObject target;
public bool rotate = false;
//adapted from https://gamedev.stackexchange.com/questions/95379/rotating-an-object-continously-with-onmousedown
void OnMouseDown()
{
rotate = !rotate;
}
void Update()
{
if(rotate)
{
target.transform.Rotate (new Vector3 (0,15,0) * Time.deltaTime * 5);
}
}
}
^^^ that is my current code that makes each cube rotate when clicked individually; would like to keep the zoom code in that too? If that's possible?
Thanks in advance and sorry for stupid question but am so confused...
Your answer
Follow this Question
Related Questions
Get object orientation 3 Answers
How to make camera zooming with a range? [C#] 0 Answers
Zooming in and out with an orthographic camera, while the bottom edge is fixed. 0 Answers
Make player face same direction as camera. 4 Answers
Camera scripting references 0 Answers