Help How to select the obi rope by mouse click? - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Help How to select the obi rope by mouse click? (/thread-602.html) |
How to select the obi rope by mouse click? - cowill - 17-05-2018 Hi, everyone. I create some obi ropes in my game, then I need select them by mouse click (Input.GetMouseButtonDown) in game window, such like using Physics.Raycast to know whether mouse click on the rope , however the conventional way does not work . Any one help to solve this problem? Thanks a lot. RE: How to select the obi rope by mouse click? - josemendez - 17-05-2018 (17-05-2018, 02:58 AM)cowill Wrote: Hi, everyone. I create some obi ropes in my game, then I need select them by mouse click (Input.GetMouseButtonDown) in game window, such like using Physics.Raycast to know whether mouse click on the rope , however the conventional way does not work . Any one help to solve this problem? Thanks a lot. Hi there, You can simply raycast against the rope mesh, why wouldn't that work?. You can get a reference to it from its MeshFilter component. RE: How to select the obi rope by mouse click? - cowill - 21-05-2018 (17-05-2018, 08:54 AM)josemendez Wrote: Hi there, Hi josemendez, thanks for you reply, I'm new in Unity. My problem is how to add a suitable collider to the rope mesh? Physcis.Raycast needs a collider. I added a mesh collider to the Rope Mesh, but the collider is fixed when the rope is animating. My solution so far is updating the mesh collider in Update() function. Like this: Code: void Update () { RE: How to select the obi rope by mouse click? - josemendez - 21-05-2018 (21-05-2018, 03:18 AM)cowill Wrote: Hi josemendez, thanks for you reply, I'm new in Unity. My problem is how to add a suitable collider to the rope mesh? Physcis.Raycast needs a collider. I added a mesh collider to the Rope Mesh, but the collider is fixed when the rope is animating. My solution so far is updating the mesh collider in Update() function. Like this: You could only update the mesh when the user clicks, no need to do it every Update(). RE: How to select the obi rope by mouse click? - cowill - 24-05-2018 (21-05-2018, 08:41 AM)josemendez Wrote: You could only update the mesh when the user clicks, no need to do it every Update(). Thanks a lot. |