A gameobject(cylinder) moves along with the Hand tool (top-left corner) when right clicked, even when the gameobject is not selected
I wrote a javascript to move a cylinder on clicking. But the cylinder starts moving around in the scene when the hand tool is selected and I right click. Moreover, on pressing play, the cylinder is not visible. Here's the script (VisualStudio):
var target:Transform; function Update () {
} function OnMouseDown () { this.transform.position=target.position; this.transform.parent=GameObject.Find("FPSController").transform; this.transform.parent=GameObject.Find("FirstPersonCharacter").transform; } function OnMouseUp() { this.transform.parent = GameObject.Find("FPSController").transform; this.transform.parent = null;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612114615im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Deselecting all the other Units when selecting a Unit 0 Answers
How to move a game object to a position after selecting it 0 Answers
Limited response from mouse input in game view. 2019.3 0 Answers
Click on different objects to move the camera 2 Answers
Move object to another position after Mouse Click with MoveTowards function 1 Answer