playMaker

Author Topic: Rotate the player about X degrees and move straight  (Read 2144 times)

Tomasz

  • Playmaker Newbie
  • *
  • Posts: 34
Rotate the player about X degrees and move straight
« on: October 26, 2016, 11:29:05 AM »
I have an idea how to solve my problem with the rotation of the player, about which I wrote in this thread:
http://hutonggames.com/playmakerforum/index.php?topic=11075.0

The solution, though perhaps I should say the idea is very simple, but I have no concept how to do it, which is why I call for help!
help help help! ;-)

Solution is:

* I press the left arrow than the player is rotated 90 degrees counterclockwise and begins to move steadily forward until the player hits the other trigger object which cause another action.

* Pressing the right arrow causes a similar action but first is turn to the right and than move forward.

* Pressing the down arrow makes the player rotates 180 degrees and move forward.

* And when I will press up arrow the player just go forward.

* Of course, movement is in the direction in which the player is rotated.

This is a very simple way, but for me quite perfect,
because there is no problem with the rotation of the player while making a move, as it is described in the linked thread at the top.

Currently, to move the player I use Move Towards action.
But this action allows me to direct the player to other object or to a designated point, and I need to turn the player about X degrees and move him forward.
How can I do this? Could somebody give me a hint?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate the player about X degrees and move straight
« Reply #1 on: October 27, 2016, 04:06:15 AM »
Hi,

 Interesting case. The key here is to decouple inputs and animations.

Have one Fsm dealing with inputs and it sends an event when input is down as well as when input stopped.
Then, another fsm is listening to them events and in sequence, rotates, and then move forward.

when trigger, the trigger should send an event to the fsm watching for input so that it stops watching inputs.

 Please check the sample linked below. You'll see three simple Fsm, one for checking and forwarding Input commands, one for rotating and moving character in sequence and one for triggers. When your player hits a trigger, the Input fsm is expected you to press Space bar to resume input commands and start controlling the player again.

https://github.com/jeanfabre/PlayMakerCustomActions_U4/blob/master/PlayerSequencedControl.unitypackage?raw=true


 Hopefully this will help you getting in the right direction for this behaviour.

 Let me know if you have questions.

 Bye,

 Jean

Tomasz

  • Playmaker Newbie
  • *
  • Posts: 34
Re: Rotate the player about X degrees and move straight
« Reply #2 on: October 27, 2016, 06:18:15 PM »
Thank you for the beautiful example!
I analyzed it, and I saw how to use two actions, so I take them into my project: I Tween Rotate To and Translate.

The effect is for about 2 seconds I hear the very gentle sound disruptions, as if the player is turned in another some space. Space from the other alien scene, because the main sounds from my scene come from the same places. Then the player begins to move forward.
No matter how many degrees of rotation I will set in I Tween Rotate To the player is always going in the same direction.

I have the same setting in I Tween Rotate To. Did I missed something?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Rotate the player about X degrees and move straight
« Reply #3 on: November 01, 2016, 03:43:53 AM »
Hi,

yes, the rotation is absolute. Check again my sample and how I compute the rotation prior tweening.

Bye,

 Jean