Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: charcoal on May 01, 2012, 01:34:55 AM
-
I am wanting to use the mouse to move an object in the xyz axes. I have created an object and added Get Mouse Button Down, Mouse Pick and Set Position. When I mouse click the screen to move the object to another position it moves to 0,0,0 in world space. I want the object to move to the postion where the position of mouse is when clicked on screen in xyz world space. I have created a variable called clickedPosition with vector3.
-
Take a look at the PlaymakerSamples\TestLab\Input\ClickMoveTo sample scene.
Does the object you're clicking on have a collider?
-
Hi Alex,
Yes the object does have a collider. I want to click and drag the object anywhere in world space. I do not want to use a plane for the object to move on. I will have a look at the example you mentioned.
-
Did the example help?
I want to click and drag the object anywhere in world space. I do not want to use a plane for the object to move on.
Not sure what you mean... you have to translate the 2d click position into a 3d world position. Typically you use Mouse Pick or Raycast to get a 3d position in the world. The world can have any number of colliders, including Mesh Colliders, so you can make pretty much any clickable surface shape you want...
-
I think his ground is going to be either a terrain or some sort of non flat surface.
-
Hi Alex,
Yes I got the object to move along a plane using the mouse button. However I want to remove the plane altogether from the scene, and have the object move in world space all by itself using the mouse button. It seems I can only move an object if there is another object in the scene which it uses as a surface to move on.
-
You could use Screen To World Point:
https://hutonggames.fogbugz.com/default.asp?W570
You can use the mouse position for screen x and y, and some fixed distance for z. This moves the object on an imaginary plane in front of the camera... Is the what you're looking for?
-
Hi Alex,
Screen to World Point is working, thanks. But each time I click to move the object it comes closer and closer to the camera and then it eventually it disappears. Also the object only moves if I click on the side of it, and I would like to smoothly drag it to another location. Any suggestions how to solve these problems would be appreciated. Ultimately I want to be able to create an multiple objects in world space with a click of the mouse, and then select them and move them about.
-
I have got the object now moving freely in world space using Screen to World Point and Set Position. In Set Position I have set the Z vector to -5 to stop the object moving closer to the camera each time I click the mouse button. I have one problem left where I want to be able to click and drag the object, but I seem to be only able to click and place the object. Can anyone help?
-
Hi,
Two options, depending on if you want to use physics or not:
http://hutonggames.com/playmakerforum/index.php?topic=1286.0 (http://hutonggames.com/playmakerforum/index.php?topic=1286.0)
http://hutonggames.com/playmakerforum/index.php?topic=272.0 (http://hutonggames.com/playmakerforum/index.php?topic=272.0)
Bye,
Jean
-
Thanks Alex and Jean, it is working nicely now.