playMaker

Author Topic: Mouse Pick Problem [SOLVED]  (Read 2019 times)

Aaal

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Mouse Pick Problem [SOLVED]
« on: March 25, 2013, 07:30:31 AM »
Hi,

I have read through the mouse pick tutorial, read through those questions and answers, read through the net on possible solutions but I still cannot get the mouse pick video tutorial working. The problem lies in the mouse pick returning the vector of (0, 0, 0) no matter where the mouse is clicked in the game scene.

Things that I have done:
1) Have only one camera in scene and set that as Main Camera (both in name and even the tag used by Unity default setting)
2) Set the ray range to be > 100. In fact I used till 5000.
3) Have my sphere quite close, but not too close, to the camera
4) Both sphere and plane have colliders

And yet, I am still unable to detect a different vector3 return other than all zeros. It always return the 'cancel' state (from the video). Anyone who had this problem before and able to solve it? thanks
« Last Edit: March 25, 2013, 01:14:17 PM by Aaal »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2501
  • Mender of the past
    • View Profile
    • Cleverous
Re: Mouse Pick Problem
« Reply #1 on: March 25, 2013, 07:53:44 AM »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Aaal

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Mouse Pick Problem
« Reply #2 on: March 25, 2013, 12:40:26 PM »
Hi Lane,

Thanks for your link. I have tried that under a new project and it works. However, as I was trying to do point to point comparison (logic-wise), I am still unable to find out what's wrong with my setup (according to the video on mouse pick).

Everything was correct. I deleted my old camera, plane and sphere, and simply recreated new default ones. Camera has been seen to MainCamera, both plane and sphere are confirmed with colliders attached. Raycast 100 - 5000 values been tested. The states and variables have nothing wrong about them.

However, there's one thing that strikes my curiosity. There should be nothing wrong with mouse pick and left mouse button down has already executed. However, my vector3 resulted in V(0, 0, 0) while yours returned good values (I simply retrieved as a vector3 value on your example on each intersection of the click).

I am still wondering what's wrong...

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2501
  • Mender of the past
    • View Profile
    • Cleverous
Re: Mouse Pick Problem
« Reply #3 on: March 25, 2013, 12:55:10 PM »
Not really sure, I would have to see your scene since I can't think of much off-hand.

Are you sure you've selected a vector3 for it to store the point data into? Layer Masks set to 0?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Aaal

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Mouse Pick Problem
« Reply #4 on: March 25, 2013, 01:13:54 PM »
Hi Lane,

Thanks again for your link. I have managed to solve the problem. I believe there are other new FSM users out there who skipped this problem as they mentioned on the other websites.

But you (Lane) really helped a lot. Down to the core, I cut and paste each of your elements such as camera, wall, plane and tested right to the micro details. When all else failed, I finally cut and pasted your selectManager game object and it worked fine again. Hence, the problem should lie in my InputManager object (as mentioned in the video).

I laughed a bit but guess this problem might arise due to new FSM users. Probably the video should have advised a little on this.

Solution: Put the bool test condition AFTER mouse pick. If not, it will always detect as 'cancel'/false and will not deliver the vector3 results in assigned variable. And thus, the intersection will never occur. In short, sequencing of your actions in the state must be correct in order.

Haha, ya... I'm laughing at myself now... took me half a day to figure out why. Never expect this could be the problem. Good luck guys! thanks Lane!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2501
  • Mender of the past
    • View Profile
    • Cleverous
Re: Mouse Pick Problem [SOLVED]
« Reply #5 on: March 25, 2013, 01:59:05 PM »
Hah, yeah a majority issues end up being simple mistakes.

Glad the scene helped.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D