playMaker

Author Topic: How to rotate object around axis using the mouse(X&Y)  (Read 11413 times)

ghost010

  • Junior Playmaker
  • **
  • Posts: 51
How to rotate object around axis using the mouse(X&Y)
« on: March 10, 2014, 06:54:28 AM »
I'm currently looking at Angry Ships and it has almost the exact movements i need. apart from 1 issue,its a top down.
And im making a side scroller.
The smooth look at and mouse pic does almost do what i want it to do.
There is a mouse pic 2D..but not look at 2D.

Any solutions to this?
Id hate to flip my project to top down.


After finally looking into how the code was build up,the example didn't do what i wanted.
Instead i want the object to rotate on its axis,so when i point my mouse up,it will go up,just like a joystick(this is all in a 2D fashion).
I'm not only looking at 1 axis because i want the space ship always point up with its roof.So when facing left or right ,it will stil have the roof on top.
For up and down,it doesn't matter.Up can be bottom or roof,same go's for down.

I also changed the topic name to How to rotate object around axis using the mouse(X&Y)
« Last Edit: March 11, 2014, 10:28:27 PM by ghost010 »

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: Look at 2d?(on Y instead of X or Z)
« Reply #1 on: March 10, 2014, 10:53:09 AM »
Came here looking for solution to the same problem.

I am working on a 2D prototype and my sprite keeps on turning away from the view. Can't manage to get the right settings in Look At and also experience the same in iTween Move From LookAt.

Is this as designed?
Please shed some light how this stuff should be done in 2D.

Thanks,
Peter

ghost010

  • Junior Playmaker
  • **
  • Posts: 51
Re: Look at 2d?(on Y instead of X or Z)
« Reply #2 on: March 10, 2014, 11:42:45 AM »
So far,the only option i now have is making every thing in top down view..but this doesnt work with the unity3D 2D mode ofc.

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: Look at 2d?(on Y instead of X or Z)
« Reply #3 on: March 11, 2014, 03:49:20 AM »
I knew it could be done, but was pretty hard FOR ME to get my head around this. :)
But I did it so I'm awesome!
Behold the solution I simply named: LA2DVMS = Look At 2D Vector Math Solution.  :)

Works perfectly, but please tell if there is an even easier solution.

Br,
Peter

Note: the 2 states contain the same actions except for one extra and the settings indicated with green brackets.

This will make your "character" Object (owner of this FSM) always look at the target point "node" as you move the "character" around the scene.
Works in Unity 2D.
« Last Edit: March 11, 2014, 03:55:48 AM by purbanics »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Look at 2d?(on Y instead of X or Z)
« Reply #4 on: March 11, 2014, 07:31:51 AM »
Hi,

 Nice, sounds all good to me!

Bye,

 Jean

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: Look at 2d?(on Y instead of X or Z)
« Reply #5 on: March 11, 2014, 08:50:25 AM »
Thanks Jean for checking.

What about the Look at 2D and the LookAt in the iTween move actions?
Will those be fixed? or modified to work with 2D Unity?

Br,
Peter

ghost010

  • Junior Playmaker
  • **
  • Posts: 51
Re: Look at 2d?(on Y instead of X or Z)
« Reply #6 on: March 11, 2014, 09:51:08 AM »
I'm not home yet,so i will try it once i am.(once im done making websites on my internship and work after that).

Might have to adjust some stuff to my liking.but we will see.

« Last Edit: March 11, 2014, 11:17:52 AM by ghost010 »

ghost010

  • Junior Playmaker
  • **
  • Posts: 51
Re: Look at 2d?(on Y instead of X or Z)
« Reply #7 on: March 11, 2014, 06:31:51 PM »
Its not working for me,copied every thing in the screenshot.
It just seems to rapidly change the Y axis from up to down in a loop,the mesh doesnt move at all.

Do you by any chanse have a empty scene/project with this working?

Also my paymaker looks bit different(no numbers under the vectors and such)
« Last Edit: March 11, 2014, 07:10:50 PM by ghost010 »

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Look at 2d?(on Y instead of X or Z)
« Reply #8 on: March 11, 2014, 07:29:40 PM »
Also my paymaker looks bit different(no numbers under the vectors and such)

There is a checkbox titled Debug located in the states tab. Just check that to see the numbers.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

ghost010

  • Junior Playmaker
  • **
  • Posts: 51
Re: Look at 2d?(on Y instead of X or Z)
« Reply #9 on: March 11, 2014, 08:36:26 PM »
Oke,i made a little progress.now the only thing to do is stop rotating the mesh on its local Y axis.
so it wont rotate around the Y axis when i go from the left side of the mesh to the right side(instead it should loop/circle move) only rotating around the Z axis for up down and X axis to rotate the mesh so the top/head/roof is always up.

Can we use rotation constraints?


Turns out it didnt do what i wanted.
i have an object that adds force (a rocket).
I want to let it go in a direction just like a joystick would do,but instead it always aims for the mouse it self instead of using the mouse as a pivot position?

So thats some progress for nothing.
« Last Edit: March 11, 2014, 10:21:57 PM by ghost010 »

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: How to rotate object around axis using the mouse(X&Y)
« Reply #10 on: March 12, 2014, 03:06:48 AM »
Please explain exactly what you would like to achieve. I am sure that with little but the right modification you can make a rocket follow your mouse.

If that is what you want??? I'm not sure.

Br,
Peter

ghost010

  • Junior Playmaker
  • **
  • Posts: 51
Re: How to rotate object around axis using the mouse(X&Y)
« Reply #11 on: March 12, 2014, 04:07:45 AM »


I actually made a custom action that does what the first 2 screens show.
But i need the last screen.

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: How to rotate object around axis using the mouse(X&Y)
« Reply #12 on: March 12, 2014, 04:21:12 AM »
Let's make sure I understand what you are trying to achieve in the 3rd one.

You don't want the rocket to follow the mouse cursor.
Instead just check once where the mouse is compared to the spawn point of the rocket, get the direction and let the rocket fly straight ahead in that direction.

Much Easier! No?

Br,
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to rotate object around axis using the mouse(X&Y)
« Reply #13 on: March 12, 2014, 08:42:27 AM »

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: How to rotate object around axis using the mouse(X&Y)
« Reply #14 on: March 12, 2014, 09:18:39 AM »
Thanks, Jean!

No, I did not know there was a custom script/action that solves this problem.

I'll keep on using my figured out vector math solution for now.
Do you plan to add that to the next build?
(Next time I wouldn't have to mess around with math stuffs.)
:)

Thanks,
Peter