playMaker

Author Topic: constrain position  (Read 6622 times)

gamedivision

  • Full Member
  • ***
  • Posts: 227
    • View Profile
Re: constrain position
« Reply #15 on: June 01, 2012, 03:02:31 AM »
hi jean could you elaborate some more on the get property for the joystick,so what i need to do is map the movement of the joystick to the movement of the character on screen,do i use get property then select the target object which is the joystick then the property would be transform and store that in a vector3 if i can



thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12417
  • Official Playmaker Support
    • View Profile
Re: constrain position
« Reply #16 on: June 04, 2012, 03:52:23 AM »
Hi,

 yes, exactly, you will need to access the property of the joystick component, be it the vector2 or the individual axis ( as float), then you will have your values inside playmaker variables, available to be injected to your character controller ( you got that part covered I think)

I would suggest that you first create a Fsm Object variable, set its type of "joystick", then use the "get property" action referencing this Fsm Object, it will work very well like that.

 Bye,

 Jean

gamedivision

  • Full Member
  • ***
  • Posts: 227
    • View Profile
Re: constrain position
« Reply #17 on: June 05, 2012, 11:34:45 AM »
your dual joystick already takes and stores the vertical and horizontal values and stores them into a float,sorry to bore you with the constant questions,how would i take those values from the floats and move something around the screen

on the create a third person controller tutorial he uses a vector3,get axis vector,controller simple move.but on your dual sticks your using floats


also another thing i dont understand,if i add a get property to your dual joystick choose transform,which is what i thought would be the x,y,z.
when i go to choose store object ,none of my variables show.

plus i dont understand what an fsm object variable is,i see get and set fsm object



thank you
« Last Edit: June 05, 2012, 02:20:09 PM by gamedivision »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12417
  • Official Playmaker Support
    • View Profile
Re: constrain position
« Reply #18 on: June 06, 2012, 12:12:53 AM »
Hi,

 1: I think you are over thinking this. The package I provided is merely the start for you to understand how the joystick works. I have attached a working package showing how to control a cube movement and rotation.

 the basic building block for this is to use the action "Joystick Bridge" and then plug the vertical and horizontal value into other actions performing something with the transform of a gameObject or else.

so in that example, I bind the right pad values to transltate the cube and I bind the left pad values to rotate the cube.

you might get confused as to how to do that from the prefab itself. You can absolutly implement your control IN the prefab itself, but it's also perfectly acceptable to not use that ( remove them Fsm if you never going to use them) and do as I did, simply implementing joystick bridges where ever you need it.


2: No you don't want to get the transform of the joysticks, you only want to use the values passed with the joystick bridge, the rest is only internal and will not reflect in a convenient way what you are after.

If you want to put the joystick bridge values into a vector 2 or vector 3, you can compose very easily the component of them vectors and insert in them the joystick values, you then pass that composed vector to your controller.

3: Fsm Object are a very convenient way to access public variables of any components available in your project, this effectily remove the need to have to create a custom action for each of these cases where playmaker can simply not provide an action for each individual api and behavior available in Unity, that is simply not a realistic task.

so, concrete example:

you want to control the field of view of the camera but you haven't spotted that an action exists for it. no problem.

1: drag a "set property" action onto a state,
2: drag and drop the camera component itself onto the "target object" field. you'll notice that the ObjectType informational field will switch to "UnityEngine.Camera"
3: select the "fieldOfView" property available int he drop down list of the "Property" field. a Float select will be shown
4: set the field of view float value here.

a Fsm Object can be ANY behavior currently available in your project and will like ALL pubic variable that Playmaker can handle

so instead of using set property and dragging the component you want to control
1: create a Fsm Object in the variable tab.
2: select the Object type to Unityengine.Camera
3: drag and drop the camera gameObject in the "objectValue" field
4: In the state where you have your set property, reference that variable in the "target object" field and proceed as usual to set one it property.

Hope this make more sense now. I am pretty sure one of the video tutorial do cover this, but I haven't watched them all, so can't say for sure.

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12417
  • Official Playmaker Support
    • View Profile
Re: constrain position
« Reply #19 on: June 06, 2012, 12:31:54 AM »
Hi,

 I made a working example of this Fsm Object usage. So have a look at this for a real integration of that.

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

Bye,

 Jean

gamedivision

  • Full Member
  • ***
  • Posts: 227
    • View Profile
Re: constrain position
« Reply #20 on: June 07, 2012, 02:14:17 PM »
Sorry I haven't replied,my dog was really sick,she had a massive operation,had a big tumour removed from her leg.but she's on the road to recovery ,soon as I get the chance to try this I will,I can't wait,and thanks for helping me out,I didn't realise the transform would do that on the object you need to move.

gamedivision

  • Full Member
  • ***
  • Posts: 227
    • View Profile
Re: constrain position
« Reply #21 on: July 20, 2012, 12:24:27 PM »
in the demo scene you provided with the double joystick and the box,what actually controls the speed of the box,so say if i wanted the box to move quicker