PlayMaker Help & Tips > iOS Help

constrain position

(1/5) > >>

gamedivision:
how would i constrain the position of a thumbstick to the base

thanks

jeanfabre:
Hi,

You would have two different behavior,

1: when the user is touching, the thumbstick need to move with the touch position within the allowed range. for this there is an example that you can adapt.

https://hutonggames.fogbugz.com/default.asp?W882

 effectively, instead of using the usual input to move it, you would use the touch position.

2: When the user releases the touch  ( or it was cancelled)

you would simply animate back the thumbstick back to its base using for example iTween.


Bye,

 Jean

gamedivision:
for the return position i used a setposition in the idle state,but there is a bug with touch object event,when you slide your finger off the thumbstick it doesn't trigger the touch ended,touch cancelled,so your stuck in the touched state.so therefore it cant jump to its set position in the idle state.


--- Quote from: jeanfabre on May 28, 2012, 01:38:13 AM ---Hi,

You would have two different behavior,

1: when the user is touching, the thumbstick need to move with the touch position within the allowed range. for this there is an example that you can adapt.

https://hutonggames.fogbugz.com/default.asp?W882

 effectively, instead of using the usual input to move it, you would use the touch position.

2: When the user releases the touch  ( or it was cancelled)

you would simply animate back the thumbstick back to its base using for example iTween.


Bye,

 Jean



--- End quote ---

gamedivision:
so looking at this example you have
get axis     (this gets the horizontal movement and stores it in the translation variable) 
float multiply  (this reduces the translation variable by however many increments you  want)
translate       (another guess that this puts the variable into real world co-ordinates like an x value)
get position   (not sure what this does)
float compare (these i think compare the current position  with the limit position,if it reaches the limit position then fires off the limit state,which in turn stops the movement with the set position)
float compare

for an actual thumbstick
id need to compare the horizontal and vertical axis so i suppose i need to use the get axis vector and a get touch info as well as a screen to world point then a set position
this im completely guessing haha,but a pointer in the right direction would be very helpful indeed,i read that the touch info stores the delta position which is the movement of touch using a vector3 variable,so maybe i wouldnt need the get axis vector
ohh i dont know


--- Quote from: jeanfabre on May 28, 2012, 01:38:13 AM ---Hi,

You would have two different behavior,

1: when the user is touching, the thumbstick need to move with the touch position within the allowed range. for this there is an example that you can adapt.

https://hutonggames.fogbugz.com/default.asp?W882

 effectively, instead of using the usual input to move it, you would use the touch position.

2: When the user releases the touch  ( or it was cancelled)

you would simply animate back the thumbstick back to its base using for example iTween.


Bye,

 Jean



--- End quote ---

gamedivision:
so just to get started ive come up with this,the only problem is,it doesnt work haha
if i remove the float compare and get position then you can drag your thumbstick around the screen but with no limits.so the problem i have is limiting this to the circumference of the base,what i tried to do was use the float compare from your example but once at the limit range it doesnt return back to the touched event using the finished transition.
so if anyone can offer some input we can try and finally get a working joystick for everyone to use.

thanks
ohh and please forgive my complete newbish attempt at making this joystick control,i have no experience at all and this was just a common sense approach,if you dont try theory.

Navigation

[0] Message Index

[#] Next page

Go to full version