playMaker

Author Topic: Move objects on screen axes  (Read 9858 times)

marcos

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 199
    • View Profile
Move objects on screen axes
« on: April 12, 2011, 08:13:05 AM »
Hey everyone,
Just wondering how I would go about accomplishing the following:

I want to make an object move on the screen's current x and y axes with the mouse (or iOS touch) when the mouse clicks and drags (or touches and swipes).
So for example if the camera were perfectly front on, it would move on the world x and y axes, if the camera were pointing perfectly from the side it would be y and z; and if the camera were from an angle it would be a mixture of all three, but remaining 'flat' (as it were) with the screen's point of view.

Please let me know if what I just wrote made no sense at all and I'll try to clarify,
many thanks in advance.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15495
  • Official Playmaker Support
    • View Profile
Re: Move objects on screen axes
« Reply #1 on: April 12, 2011, 09:13:25 AM »
Hi,

Before giving the right answer, Few clarifications:

 do you want to move the 3d model on its own ground ( like a character moving on the ground) or do you want to move the 3d model really in the camera axis like for example an element of an interface in 3d that you drag on screen, that would be completely independent of the 3d content itself?

 I suspect from your explanation that it's the second option, but I am not sure still.

 Bye,

 Jean

marcos

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 199
    • View Profile
Re: Move objects on screen axes
« Reply #2 on: April 12, 2011, 09:52:30 AM »
Hi Jean,

The second one is what I'm after, though I don't want the object to follow the screen rotations itself like an interface item might (I don't think that you implied this, but just making sure). It would be an object floating in 3d space that ignores the depth from the camera when being moved around with drags or touch gestures.

I've attached an image (that I hope will work) that hopefully explains everything.

Thanks again.

MaDDoX

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 165
    • View Profile
    • FluidPlay Studios
Re: Move objects on screen axes
« Reply #3 on: April 13, 2011, 09:37:46 AM »
--
Breno "MaDDoX" Azevedo
@brenoazevedo

marcos

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 199
    • View Profile
Re: Move objects on screen axes
« Reply #4 on: April 13, 2011, 11:40:53 PM »
Hey,

Gave that a go.
Caused the object to move forward a little bit at the start, and then move when i moved the mouse, only the object moved on its own XY axes, rather than in screen space. Also tried with Set Position and had similar results.
Will keep plugging away and see if I fluke it.

Many thanks for the input

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3912
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Move objects on screen axes
« Reply #5 on: April 14, 2011, 03:15:27 AM »
If you want the object to move on a plane in front of the camera, use Camera -> Screen To World Point

Set Z to the depth into the screen, and set X and Y with Get Mouse X and Y. Or use mouse movement using Get Axis.

I'll put together an example if that doesn't help...

marcos

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 199
    • View Profile
Re: Move objects on screen axes
« Reply #6 on: April 14, 2011, 03:54:45 AM »
Thanks Alex,
I'll give it a shot when I get back to my computer later tonight!

marcos

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 199
    • View Profile
Re: Move objects on screen axes
« Reply #7 on: April 14, 2011, 11:28:50 PM »
Okay, I've figured out how to move it on the screen's XY using the above when I set the Z to a fixed value. However when I try to use the distance of the object from the camera and set that to the Z depth in Screen to World Point, the object gets sent an infinite distance into the background.

I suppose I'm still climbing the learning curve a bit here!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3912
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Move objects on screen axes
« Reply #8 on: April 15, 2011, 03:59:50 PM »
Screen To World Point is good for placing a game object on an imaginary plane in front of the camera (e.g. HUD, picked up objects...)

To place an object in the world you probably want one of the ray casting actions (MousePick, ScreenPick, RayCast...).

Have you looked at PlayMakerSamples/TestLab/Input/MouseClickToDrag? Is that something like what you want to do?

marcos

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 199
    • View Profile
Re: Move objects on screen axes
« Reply #9 on: April 16, 2011, 07:19:58 AM »
It's similar, but rather than having the object move about on a plane, I'm trying to get it to remain the same distance from the camera and move it around then XY of the screen. Then being able to orbit the camera around, and move the object around the new XY of the camera and so on.