Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: gamedivision on February 17, 2013, 08:28:43 AM

Title: less than greater than
Post by: gamedivision on February 17, 2013, 08:28:43 AM
do we have anything in the form of if less than but greater than do this or do that event

thank you
Title: Re: less than greater than
Post by: kiriri on February 17, 2013, 09:03:31 AM
Hey,
let's say  we want to check if something is smaller than 10, but bigger than three:
Then we first use a float compare which checks if the float is bigger than 3. If it is smaller, this action sends the FAIL event. If it is bigger, it sends nothing.
Then in the same state we add another float compare action (after the previous one). This action now compares if the float is smaller than 10. If it is, it sends the event FINISHED. If it isn't, it sends FAIL.

So what we end up is a state that sends FAIL if either of the 2 conditions is not met. It sends FINISHED if both are true.
Title: Re: less than greater than
Post by: gamedivision on February 17, 2013, 09:48:02 AM
ahh so it doesn't pass to the next float compare unless it satisfies the first
Title: Re: less than greater than
Post by: kiriri on February 17, 2013, 09:56:39 AM
yep, states are processed top to bottom :) It allows for a number of awesome techniques  ;)
Title: Re: less than greater than
Post by: will_brett on February 17, 2013, 01:22:41 PM
This video explains something very similar really well.

Title: Re: less than greater than
Post by: gamedivision on February 17, 2013, 04:15:29 PM
thanks for the replies,it seems everything i do so far doesn't work , i have to compare 3 different positions using swipe up and swipe down,swipe up needs to check if its below a certain point then it can move to either middle or top and swipe down needs to check whether it can move middle or bottom,now with your theory kiriri because it processes from top the most you could ever put in my situation would be 2 compares,so it will never process whether it needs to move to the middle or not. im stuck completely thats why i wanted to use itween move add because i could compare the position and move by 5 or whatever then i would get my positions but it just doesnt want to move to exact numbers,same with all the move actions none are exact .
Title: Re: less than greater than
Post by: gamedivision on February 18, 2013, 07:05:30 AM
I wonder if I can solve this via booleans ,or I'm wondering if I could cycle through game objects using get child,I could position empty game objects around my box front rear middle left and right,make child objects of the the front object.then on the box use a get poisition and store the z value which is moving forward in a float,then use a set position on the front empty game object,and set the z position so the left and right empty game objects stay in the same position when I move, therefore I could use those left and right game objects as positions to move to when I swipe.
So I could store those and use I think.
Title: Re: less than greater than
Post by: kiriri on February 18, 2013, 10:35:03 AM
Hey can you describe you're problem a bit further? I'm sure there is a simple solution, there always is, but I don't seem to grasp your setup  :-\
Title: Re: less than greater than
Post by: gamedivision on February 18, 2013, 10:55:58 AM
Sorry I tend to over complicate things.
Image a box moving continuously in one direction say down the Z axis,when I swipe up the box moves left on X axis,when I swipe down the box moves right X axis,but only in three locations middle 0,left 5,right -5 depending on the scale and position.
Hopefully that's made it easier to understand

Thanks for the reply  ;D
Title: Re: less than greater than
Post by: kiriri on February 18, 2013, 11:26:59 AM
I too am most horrible at explaning my problems to others , which is why I seem like I know it all :D
ok, let's see if I got you.

The game starts and we see a cube that is slowly moving (translate every frame per second) from the top of the screen to the bottom.
Now the player can touch anywhere on the screen and quickly move his finger to initiate a "swipe" . Depending of the start - end position of the swipe (the direction) it will be counted as swipe left, right, up or down.

And here's where I'm getting less certain:

If the player does a swipe left, it should start moving the cube on the negative x direction (as well as still continuing on the z axis) ? Continuously or does it only move shortly (like with a rigidbody force) ?

Then it should move until the x position is either 0, -5 or 5 ?

Dense me  ;D
Title: Re: less than greater than
Post by: gamedivision on February 18, 2013, 12:43:15 PM
the swipe will be up to move left and down to move right
Title: Re: less than greater than
Post by: gamedivision on February 18, 2013, 12:44:58 PM
zero would be the middle then plus 5 minus 5 so three positions to move in
Title: Re: less than greater than
Post by: kiriri on February 18, 2013, 01:01:19 PM
so maybe you need "clamp float" ?
If you get the current x position every frame, clamp it to -5 to 5 every frame and then set the position to that value every frame, it will be restricted to -5 to 5 as long as the state runs.

Was that it?
Title: Re: less than greater than
Post by: gamedivision on February 18, 2013, 02:00:08 PM
ill post a picture which will better explain
Title: Re: less than greater than
Post by: gamedivision on February 18, 2013, 02:17:39 PM
(http://img542.imageshack.us/img542/884/moveposition.jpg)
i hope this better demonstrates my scenario,as you can see the box can move to either of those 3 positions using a swipe to move,remembering that the box will be moving forward all the time.
Title: Re: less than greater than
Post by: gamedivision on February 18, 2013, 02:25:03 PM
i dont know why i didn't show this earlier,but i created this 2d game in another game engine and im re-creating it in 3d,i never released this game so this is the movement im trying to re-create with more of a dynamic camera,at 27 secs in you can see the movement of the character with the swipe.
Title: Re: less than greater than
Post by: gamedivision on February 19, 2013, 08:25:25 AM
(http://img17.imageshack.us/img17/7990/swipemove.jpg)
Solved not sure if it could be better resolve but its done anyway.
first state detects swipe up or down
swipe up, first finds out whether the box is within position to move,then it checks whether the position is bottom or middle,if its bottom it moves to the movemiddle state,which in turn moves the box to zero with a send event giving it enough time to there,that then rolls back to the detect swipe state.
same with all the other positions if its in the middle and you swipe up the position of the box will be zero therefore it can only move in one direction.
on another FSM i have the move towards,that moves the box in one direction continuously.
surrounding the box i have empty game objects,all a distance of 3 away but this could be anything,on the move towards i just drag the target object in and done works great.
i dont know if anyone else maybe has a better option for how this would work.
thanks for the help so far