- Home /
Scaled object immune to clicking
I have a sphere in my program that you click on once. After the click an object is instantiated and the sphere's transform.localScale is reduced by 10 (originally 100). After the scale down takes effect I cannot click on the object again. I've tried detecting the mouseButton input after both OnMouseEnter and OnMouseOver. My most recent attempt is using a raycast here:
if(Input.GetMouseButtonUp(0)){
print("Click");
var hit: RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, hit)){
grabbed = hit.transform.gameObject;
Debug.Log(grabbed);
}
if(grabbed != null){
print("Click");
if(grabbed.tag == "nucleus"){
print("Boom");
Instantiate(node, Vector3(0,0,200), Quaternion.identity);
transform.localScale.x = transform.localScale.x -10;
transform.localScale.y = transform.localScale.y -10;
transform.localScale.z = transform.localScale.z -10;
} else {
print("Fail");
grabbed = null;
}
}
}
I cannot get any of these options to work. Is scaling my object somehow changing it's depth or click-ability?
Thanks
What is the object's original scale? By default, an object's scale is set to Vector3(1, 1, 1), and reducing it by 10 would make the scale Vector3(-9, -9, -9).
Your answer
![](https://koobas.hobune.stream/wayback/20220613081239im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Raycasting to turn varible on and OFF 1 Answer
Finding Distance between Angles and Points 2 Answers
Gun Script Help 2 Answers
Collision point on surface? 1 Answer