PlayMaker Help & Tips > Android Help

change direction on touch

(1/4) > >>

Damian:
Well i do want to know how to do this with playmaker.

Lets say i have a character that i want to move him left and right.
He is always moving up or down depending on where it is.
So i want to move him left or right when he does that.
I want to make a gui texture on my bottom on the screen for the left and right button.
When i press one of those it shall go left or right.
Its a touch screen so it must work with that and with the gui texture.

How can I do this with playmaker??

giyomu:
Using the action guielementHitTest, and get the touch coordinate on screen ( there is an action for this ), so you can test if the touch hit he guitexture, form there either you flag a bool ( using global var can be good if you control your player in anther fsm, or send an event.

for a game i am doing i went with separate Fsm to detect the guiTexture input then flag between 2 global variable, on my another Fsm for player control ( in my case i just rotate left or right ) the player fsm check for the global variable and drive to 2 event ( one for left , other for right)

while turning right or left then i still check the corresponding boolean var so when the Fsm that handle GUIHIt set it to a false state, i can then stop my rotation, back to the previous Fsm that listen for both global and so on

that's one way to do , but it is not really complicate setup to do...

Damian:
Well try that.
the character is controlled by an other script, but not FSM.
Sure i will try to change that to, but right now i want to check this out.

Can i send that action to fake a leftright.x=Input.GetAxis.....  ??
Or just transform.Translate(leftright);


EDIT.

Well i did put a GUI texture on the screen and can read it.
I can also move the character.
But thats my next problem.
How do I get the player position(vector3)?
How i can add/remove one unit from the x- axel that the character has?


giyomu:
you can use GetPosition to find our current player position , eventually you want put those into global variable , that may be easier to set that between Fsm.

then you can use Set action for vector 3 or Set Fsm Vector3 if you need to access it from another Fsm, using a global var you will just need to hook up your global form whatever Fsm you want

If you are using regular script for your player , well I eventually encourage you to pass that into full dedicated Fsm for your player movement that will be easier to manage Fsm call etc...

I usually avoid having too much script <> fsm things, as I find it clutter more teh whole things that use all stuff within Fsm , or I just write custom action specific to the game.

otherwise you can communicate with script from Fsm , and form your script to Fsm , you just need to look up the playmaker functions in regular code.

Damian:
Yes i did find some stuff that did work, but then all just breaked and now nothing seems to work.
But I will do a testlab and try do move around a block or something to see if i can figure all things out.
I guess i will learn soon, its so hard to change from coding to playmaker.
But i know it will be very useful in the end.

Navigation

[0] Message Index

[#] Next page

Go to full version