playMaker

Author Topic: Get mouse position?[SOLVED]  (Read 15050 times)

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Get mouse position?[SOLVED]
« on: January 26, 2012, 09:02:41 AM »
Hey all~

Is there a way I can get the current mouse x y z so that I can use this string and then convert it to a vector 3?
Then using this vector3 for a rotation value?

Thanks in advance
« Last Edit: January 30, 2012, 07:25:14 AM by Grave_sts »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Get mouse position?
« Reply #1 on: January 26, 2012, 03:12:14 PM »
Check out the Get Mouse X and Get Mouse Y actions.

You can also get mouse movement with GetAxis and "Mouse X" and "Mouse Y" as the axis names. Or GetAxisVector if you need a vector.

BTW, the Action Browser has a search field, so you can type "Mouse" and instantly see all actions that have Mouse in the name.

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get mouse position?
« Reply #2 on: January 27, 2012, 01:00:23 AM »
Thanks~ I tried the get mouse x and y, but it is not giving me the desired result for some reason, that's why I was curious ;) Anyhow what I am trying to do is from the current mouse position spawn a prefab that is set to the angle of the mouse i.e so that it tracks the surface and spawns the object at the desired surface normal ;)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get mouse position?
« Reply #3 on: January 27, 2012, 02:02:48 AM »
hi,

 I think you need then a custom actions like this one:

http://hutonggames.com/playmakerforum/index.php?topic=272.0

It allows you to get the mouse position ( and drag) from a defined plane in the 3d space.

If the surface is actually a mesh, then you'll need to use raw raycasting instead.

Hope it helps.

 Bye,

 Jean

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get mouse position?
« Reply #4 on: January 27, 2012, 04:32:43 AM »
Thanks Jean~

I've looked at the example you made on raycasting and changed it to allow for an on clicking event to create a prefab, the only thing I seem to be missing the plot for is getting the created prefab to match the "hit visual's" angle ;)

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get mouse position?
« Reply #5 on: January 27, 2012, 05:13:07 AM »
No worries I got it to work~ ^^ Thanks for all the input guys really appreciate it :D~ You guys are legends ~!

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get mouse position?
« Reply #6 on: January 27, 2012, 07:34:08 AM »
Hmm, ok I did something and now whenever I change the prefab that gets created from the red rectangel to a mesh for instance, the alignment of the created objects goes funky...but if i seet the spawn object to the red rectangle it works perfectly ;<

Am I missing something? Or do I have to set the meshes transforms beforehand? As I tried freezing/setting a neutral pose...

Thanks again for putting up with my series of q's
« Last Edit: January 27, 2012, 07:39:52 AM by Grave_sts »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get mouse position?
« Reply #7 on: January 29, 2012, 07:21:10 AM »
Hi,

 you're gameObject mesh is simply oriented in a different way.

 so the solution is to parent it to an empty gameObject that is oriented properly so that your mesh points in  the right direction. Compare the axis orientation of my gameObject and yours, and match it.

 Can you send me this mesh, and I'll create a working scene for you.


 Bye,

 Jean

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get mouse position?
« Reply #8 on: January 30, 2012, 12:56:24 AM »
Thanks Jean~ I really appreciate it :)~

Dropbox link: https://dl-web.dropbox.com/get/Mesh_test/Camlock_test.fbx?w=53bd9d81

>thanks again ><~

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Get mouse position?
« Reply #9 on: January 30, 2012, 07:24:38 AM »
i followed your advice with regards to the parenting and angle setup and everything is working like a dream~ ^^ thanks again guys ^^