playMaker

Author Topic: Stuck with the Axis actions :(  (Read 2421 times)

funshark

  • Playmaker Newbie
  • *
  • Posts: 23
    • View Profile
Stuck with the Axis actions :(
« on: December 15, 2013, 06:45:22 PM »
Hi there,

I'm trying to make a simple 2D "character controller" from scratch ( don't want to use the already made one on Unity ) and I can't manage to find the right method.

I'm using the Get Axis ( and Axis Event? ) because I want to be able to use a joystick and a keyboard.

When the player push the right direction, I want the player to move to the right ( pretty logic :)  ) with a defined speed ( I've created a variable for that ).
But I also want ( because I'm working with 2D toolkit ) that it plays the "Run" animation and scale the Sprite to 1 or -1 depending of the direction.

I know how to do that with push DOWN push UP key actions, but can't figure how to do with Axis. Any idea?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • Yup.
    • View Profile
    • Cleverous
Re: Stuck with the Axis actions :(
« Reply #1 on: December 15, 2013, 08:04:20 PM »
Edit>Project Settings>Input

When you use Get Axis you're getting the axis labels listed there actively. The settings in there like Gravity, Sensitivity, Dead and Snap are described in the Unity Docs and are important for setting up the feel of your controls.

Basically all you have to do is Get Axis, save it in a variable like "movementInput" and then have your controls actively translating the character position by that variable. You can do a lot even just in one state, since when they're not touching the controls the result is zero and the translation actions are basically idle.

Make sense?

It's pretty simple to get set up on a primitive level, but hard to customize a lot and polish up to a unique control system. I used Get Axis like this in the Oomph Kit, it might be of some help to look at the FSM's in there if you're extra stuck.

funshark

  • Playmaker Newbie
  • *
  • Posts: 23
    • View Profile
Re: Stuck with the Axis actions :(
« Reply #2 on: December 16, 2013, 07:42:10 AM »
Hi Jane, thank you for the reply :)

I already know about the Input options and all since I have some background in C# coding and Unity. I know how to do what I want to do in C# but not in Playmaker ( I think it's just a matter of a different approach ).

I knew that I would have some difficulties to explain the issues I have ahah :p

So, the fact is, that I have managed to do the movement ( left / right ) using the Get Axis event.
Things are getting more complicated when I want, at the same time, to modify components ( such as animation played, sprite scaling... ) on the sprite that is moved.
Don't know if it makes sense :(

however, I will take a look at your project files ( but I think I already watched a video about this, mh? )

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • Yup.
    • View Profile
    • Cleverous
Re: Stuck with the Axis actions :(
« Reply #3 on: December 16, 2013, 08:00:20 AM »
Hmm I'm not sure what the trouble is, exactly.

Quote
I know how to do that with push DOWN push UP key actions, but can't figure how to do with Axis. Any idea?

This can be sorted out just by customizing in the Input Manager.

Quote
So, the fact is, that I have managed to do the movement ( left / right ) using the Get Axis event.

So, the above issue is figured out?

Quote
Things are getting more complicated when I want, at the same time, to modify components ( such as animation played, sprite scaling... ) on the sprite that is moved.

Hmm, is this a separate issue or related to the Axis troubles?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
  • Official Playmaker Support
    • View Profile
Re: Stuck with the Axis actions :(
« Reply #4 on: December 16, 2013, 10:34:34 AM »
Hi,


So, the fact is, that I have managed to do the movement ( left / right ) using the Get Axis event.
Things are getting more complicated when I want, at the same time, to modify components ( such as animation played, sprite scaling... ) on the sprite that is moved.
Don't know if it makes sense :(


I think that the main shift of perspective for you here is to understand how to separate your feature into several disctinct Fsm. Since a Fsm can only have one active state, it's always best ( and sometime mandatory) to assign a clear and specific role to each Fsm. So in your case:

-- movement
-- sprite scaling
-- animation

typically, try to have one fsm for each feature above. It's ok if you reuse the getaxis action on each of these fsm. If you feel that's too much copy pasting, you can use global variables, else have one fsm fsm responsible for input gathering, and otherfsm simply using "get fsm float" and query that fsm for the input, that's also something very powerful cause then you can by pass user input and control programmatically if required.

bye,

 Jean

funshark

  • Playmaker Newbie
  • *
  • Posts: 23
    • View Profile
Re: Stuck with the Axis actions :(
« Reply #5 on: December 17, 2013, 08:43:26 AM »
Hmm I'm not sure what the trouble is, exactly.

Quote
I know how to do that with push DOWN push UP key actions, but can't figure how to do with Axis. Any idea?

This can be sorted out just by customizing in the Input Manager.

Quote
So, the fact is, that I have managed to do the movement ( left / right ) using the Get Axis event.

So, the above issue is figured out?

Quote
Things are getting more complicated when I want, at the same time, to modify components ( such as animation played, sprite scaling... ) on the sprite that is moved.

Hmm, is this a separate issue or related to the Axis troubles?

ahah yes it is related, it's all the same issue :)
I knew it would be difficult to understand since I don't know myself how to explain clearly why I'm stuck :(

Hi,


So, the fact is, that I have managed to do the movement ( left / right ) using the Get Axis event.
Things are getting more complicated when I want, at the same time, to modify components ( such as animation played, sprite scaling... ) on the sprite that is moved.
Don't know if it makes sense :(


I think that the main shift of perspective for you here is to understand how to separate your feature into several disctinct Fsm. Since a Fsm can only have one active state, it's always best ( and sometime mandatory) to assign a clear and specific role to each Fsm. So in your case:

-- movement
-- sprite scaling
-- animation

typically, try to have one fsm for each feature above. It's ok if you reuse the getaxis action on each of these fsm. If you feel that's too much copy pasting, you can use global variables, else have one fsm fsm responsible for input gathering, and otherfsm simply using "get fsm float" and query that fsm for the input, that's also something very powerful cause then you can by pass user input and control programmatically if required.

bye,

 Jean

Hey Jean, thanks for the help!

I think this is the right direction, and I've already started to separate the events into multiple FSM. But I have had some problems with global variables and sending events between FSM...
 
Didn't think of using one FSM dedicated to input only, seems like a good idea!
I will try all that one more time and come back if I have specific issues :)