- Home /
Question by
WesterlyCarrot9 · Dec 15, 2013 at 12:39 AM ·
c#javascriptgameobjectmousescale
Destroy object with more clicks depending on Scale?
Ok so i have this script below and with it i can destroy any object with the "smashable" tag by left-clicking when the cursor is on it. Now the next step i want to take is to require more than one click in order to destroy an object depending on the scale of it. Is there any way to do this? I was thinking about making a variable that can check the scale of the object and then if it is more than a certain amount, i need more clicks to destroy it. I also found something about Vector3.Scale..Thanks!
function Start(){
Screen.showCursor = false;
}
function Update(){
if(Input.GetMouseButtonDown(0)){
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast (ray,hit)){
if(hit.collider.tag == "smashable"){
Destroy(hit.collider.gameObject);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
when mouse is on a object do this 2 Answers
Get game component type? 1 Answer
Javascript version of 'Mouse look' script? 1 Answer
Rotate object with mouse 1 Answer
How to replace a gameobject referenced in JS using C# 2 Answers