playMaker

Author Topic: 2d Rotation[SOLVED]  (Read 5518 times)

Henrikc3

  • Playmaker Newbie
  • *
  • Posts: 3
2d Rotation[SOLVED]
« on: October 21, 2013, 03:35:27 AM »
Hey guys,
Very new to Playmaker, and been stuck for two days on 2d movement, and seems every road leads back to the linked posts below, and I just cant seem to wrap my head (correctly) around it.
http://hutonggames.com/playmakerforum/index.php?topic=272.0
http://hutonggames.com/playmakerforum/index.php?topic=270.msg1073#msg1073


I'm making a 2d top down game, and cannot currently seem to make my character move correctly.
I've managed to get it moving in the x and z axis, my problem is rotation.

(Have also tried using camera on the side, and moving in the x and y axis)

What i want is to have my spaceship rotate its nose to point at the mousepointer, while I apply force to the ships body to move it forward and sideways, but always staying in 1 plane.

Have tried "Get Mouse X and Y", storing in a variable, putting those variables into "Screen to world point", setting those 2 cordinates as the cordinates for "set vector3 XYZ", and then having my sprite "look at", "iTween look to", and "smooth look at". It just wont work.

Also tried adding in an empty game object, and "iTween move to" the game object to the "vector3 XYZ", and then having my spaceship "Look at" that empty gameobject. This was the closest I've come, as the spaceship did indeed turn and look at the gameobject, but the gameobject did not seem to be moving.

So I have tried using your mouse 3d plane drag, but unsucessful so far in figuring out how to make it work.

Would appreciate any pointers in the right direction, or some newbie friendly instruction on how to implement the 3d plane drag :)

Best regards,
Henrikc3
« Last Edit: October 22, 2013, 01:23:03 AM by jeanfabre »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: 2d Rotation
« Reply #1 on: October 21, 2013, 07:31:42 AM »
Have you looked at Angry Ships for some ideas?

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

I used a parent object with an FSM to control movement (from WASD), then on the child object I had an FSM that rotated toward the mouse intersection with the floor.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 2d Rotation
« Reply #2 on: October 21, 2013, 08:04:52 AM »
Hi,

 You may also want to study this scene attached. It features a way to project the mouse onto a 3d fictive plane, and thus allowing for look at functions.

If you have question on this, don't hesitate.

Bye,

 Jean


Henrikc3

  • Playmaker Newbie
  • *
  • Posts: 3
Re: 2d Rotation
« Reply #3 on: October 21, 2013, 04:53:59 PM »
Hi lane and Jean!

Thank you very much for your answers!

Looking into the attached scene, and also the example project Angry Ships.

Did some further testing earlier today, and found out that most likely the problem is caused by the 2d toolkit camera.

Did a fresh scene today to test. Added plane, cube, and managed to set new position based on mouse pick. Then I switched out the maincamera with the 2d toolkit camera, and it immediately stopped working.
Script was firing, but no objects was being detected when clicking on...objects.

Will restart my work using the normal camera, and just set it up normally :)

Henrikc3

  • Playmaker Newbie
  • *
  • Posts: 3
Re: 2d Rotation
« Reply #4 on: October 21, 2013, 05:40:06 PM »
Copied your (Jean) FSM script from the tank object onto my sprite. It only made it rotate around in circles (Probably because it was at 90 degree angle to show in top-down view).
So!
I decided to just add my sprite onto a cube. Not sure yet how it will effect performance, but at least it will allow me to move forward and keep learning :)