playMaker

Author Topic: Simon Says with blocks ArrayMaker issue.  (Read 9135 times)

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
Simon Says with blocks ArrayMaker issue.
« on: February 17, 2016, 01:19:09 PM »
For awhile, I have been attempting to rework sebaslive's SimonSays ArrayMaker example project to use moving cubes instead of switching materials on each of cube.

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

This is what I have so far. Click the cubes, press space bar to restart the game.

https://db.tt/yIsm0Ep3

Doesn't seem to work like the original example. Here's what I have for all three cubes for the FSMs.

https://db.tt/8X51M33U

https://db.tt/dVvdDVIQ

https://db.tt/ZfiuBpUW

I thought by using some sort of position & ease float method with the same global transitions and system events that it would work flawlessly.

Why do the cubes act this way?

Thanks.




 
« Last Edit: February 18, 2016, 03:13:31 AM by coffeeANDsoda »

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #1 on: February 17, 2016, 11:46:34 PM »
Bump.

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #2 on: February 18, 2016, 08:15:52 AM »
I couldn't work out what you were trying to accomplish based on your example and FSM's... your Cubes are caught in independent loops so won't stop animating regardless of player input. Additionally, your start state is using Get position each frame, when i suspect you want set postition (The ease float is doing nothing in this state as the float value is being reset by the position each frame). The other states are setting the cubes position at the top end of the ease float value before it starts easing back down to 0. this is why they appear to jump down moving back up slowly (i.e. you've set the float to go from 2 to 0 or 1 to 0 - If you set one to go from 0 to 2, you should have a smooth up and down animation).

Remember that you want the animation to play once, when called too from an external place. For this you use Global events (Such as your mouse down) sent to that specific object FSM. You then fire an event back to the external place saying the animation is complete. You don't want a closed loop using normal event transitions (what you've named your transition events suggests you've got confused between local and global events)

 I whipped up a quick Scene with a very basic Simon Says game using movement instead of colours for you. I've gone about it very differently to you, with everything handled by a Manager. Going into a full breakdown of it here could get lengthy.

Be sure to play around and ask if anything confuses you.


P.S.   this is the first time i've exported a scene, i'm just assuming it'll work ;)


Edit:  AssetPackage Removed
« Last Edit: February 19, 2016, 09:19:17 PM by Chizzler »

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #3 on: February 18, 2016, 12:57:12 PM »
Remember that you want the animation to play once, when called too from an external place. For this you use Global events (Such as your mouse down) sent to that specific object FSM. You then fire an event back to the external place saying the animation is complete. You don't want a closed loop using normal event transitions (what you've named your transition events suggests you've got confused between local and global events)

Last I checked, Mouse Down is the same System Event Global found in the sebaslive project I base the FSM's structure on. Since theirs a state named "Show Item" that includes three "Send Event By Name" actions relying on Mouse Down for example.

Show item state can be seen at 1:49 on sebaslive tutorial video in the URL below.




Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #4 on: February 18, 2016, 01:11:56 PM »
Currently you have a loop without any breakpoint. Whether the global mouse exit* event is fired or not, your object is progressing to that state from it's previous one. If the event is fired, it'll jump to that state from whichever state is was currently in, and it will continue from there... but nowhere does your loop stop to wait for that input it will keep repeating itself indefinitely.

The way the cubes are animating is a seperate issue, which looks to be caused by your float ease action starting at 1 or above in each state. if one state eases your float from 1 to 0,  your next one should ease it from 0 to 1, for a smooth animation, rather than it's current teleporting below your visible plane.

Edit: Sorry, just checked your screenshot again... your global event is Mouse Exit, not mouse Up/Down   those are local events.
« Last Edit: February 18, 2016, 01:14:55 PM by Chizzler »

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #5 on: February 18, 2016, 01:45:29 PM »
Currently you have a loop without any breakpoint. Whether the global mouse exit* event is fired or not, your object is progressing to that state from it's previous one. If the event is fired, it'll jump to that state from whichever state is was currently in, and it will continue from there... but nowhere does your loop stop to wait for that input it will keep repeating itself indefinitely.

In terms of ease floats, would you say set position on the set new pos state is not needed and it could be replaced with a add next frame event action if the move down state had 0 on the From Value parameter in that action located on the start state?

I was wondering if that would be a better alternative than to use move towards or itween actions? I thought about making a script for this issue, but I don't understand how that would work in relation to that custom created c# cube script communicating the FSMs(like the simonsays manager) and how transforming the cubes position would work.

Sounds like a mouth full, but that's a idea I had floating around in my head yesterday.
« Last Edit: February 18, 2016, 01:52:53 PM by coffeeANDsoda »

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #6 on: February 18, 2016, 02:09:37 PM »
For such a simple movement, I'd go with a "translate" action, though there's no right/wrong way to move something. I think your method of easing on the float value is fine, but you just need to reverse the values on one of your states to get a smooth animation rather than the teleporting that occurs.

 When you enter "set new pos" state at the moment, your float value is 0. (Unless your stuck in the start state because the get position updates your float value every frame, and it's never reaching 0). So skipping it if the float is 0, is the same as not having the state exist at all... you should never even enter that state if your float value isn't 0.

Start State:
Find game object (manager object)
*Does not connect to any state*

State 1 - Accessed through Global event from manager:
Translate (2 along Z axis per second, each frame)
Wait (1. Finish Event = Finish)
*Moves to state 2*

State 2:
Translate -2 along Z axis per second, each frame)
Wait 1. Finish Event = Finish)
*Moves to state 3*

State 3:
Set FSM bool (on Manager, so it knows animation is finished.)

*AssetPackage Removed*
« Last Edit: February 19, 2016, 09:18:41 PM by Chizzler »

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #7 on: February 18, 2016, 09:34:08 PM »
And on your end you can click on more than 1 cube at a time to mimic a sequence pattern?

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #8 on: February 18, 2016, 10:30:43 PM »
Well, currently, the cube doesn't play an animation when you click on it, so the check against the correct pattern is almost instant...

Using the Translate action alone would be a problem if you wanted to have the animation play when you select a cube and didn't force the player to wait for it's completion. It's likely to drift, because there's nothing forcing it back to it's original position.

Instead, In the start state on the Cube, add a "Get Position" action and store that vector. When the animation starts ("Move up" state) , "Set the position" before doing your Translate action.

On the manager, Send an event to the cube to play it's animation (Like it does in the first loop) when clicked but don't do the bool test to see if the animation is finished. This results in the player being able to click before the animation completes (So can quickly copy the sequence, the checks will still take place almost instantly) and the animation will simply start from the beginning each time it's clicked.

*Extra*
Doing this, you'd also want to remove the colliders from your cubes, and have each cube have an invisible collider as a parent, which doesn't move with the cube mesh. Not only is this more optimized, but you don't have to click onto a moving cube to continue your sequence.

If your referring to a multi-touch system (2 cubes firing off simultaneously as part of the pattern) then that is more complicated, you'd need to look at having multiple arrays describing the sequence "Touch 1 array" "Touch 2 array" as well as acceptable time delays between presses. It's not basic stuff. Once you become more familiar with the underlying logic, you'll be able to piece together how to implement something like that, but it's not something one could easily guide you through in a forum post.
« Last Edit: February 18, 2016, 10:57:26 PM by Chizzler »

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #9 on: February 19, 2016, 12:26:19 PM »
If your referring to a multi-touch system (2 cubes firing off simultaneously as part of the pattern) then that is more complicated, you'd need to look at having multiple arrays describing the sequence "Touch 1 array" "Touch 2 array" as well as acceptable time delays between presses. It's not basic stuff. Once you become more familiar with the underlying logic, you'll be able to piece together how to implement something like that, but it's not something one could easily guide you through in a forum post.

I'm only attempting to make a cube moving version of sebaslive simonsays example.  So it also includes three scripts. Event System, Standalone Input Module, and Touch Input Module. That can be found in the link I posted above for his arraymaker thread, so you can get an idea of where I am basing it off of.

So to be clear besides the needed scripts like in a example project, I only want to do a non-multitouch input type of game just like his(Sebaslive) scene. So you click one cube at a time after it moves up. Again, it only lets me click one cube once, not the second cube once after I click on the first cube.


Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #10 on: February 19, 2016, 03:16:37 PM »
On my end, my scene runs perfectly.  it shows a pattern, checks user input against that pattern. No problems with clicking cubes, i don't know what's happening for you there.

So, my final approach... I downloaded the example scene you were working from and made the changes you want (as far as I can tell).  It works perfectly on my end, if it doesn't work properly on your end, then maybe i'm doing something wrong with the export process.
If this doesn't work, I give up, I'm no expert at playmaker or teaching, maybe you'll have more luck from someone else helping you  :)

Any State I have changed is highlighted in Orange.

https://onedrive.live.com/redir?resid=CE23FC8B3621CDCC!537&authkey=!AE2bCgoWhU_AggM&ithint=file%2cunitypackage

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #11 on: February 19, 2016, 08:45:01 PM »
On my end, my scene runs perfectly.  it shows a pattern, checks user input against that pattern. No problems with clicking cubes, i don't know what's happening for you there.

Even after you click it once in order for the manager to create another randomly generated pattern? If it was with keys on a keyboard though, I don't see any premade playmaker system event globals for input keys, to reduce the amount of time laying out button actions when a cube moves.

Plus, what would that mean for coding when it comes to input, I was curious because I don't see coding tutorials on youtube regarding unity3d simon says gameplay? Or do you develop games only with playmaker?

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #12 on: February 19, 2016, 09:15:11 PM »

Even after you click it once in order for the manager to create another randomly generated pattern?

Yeah, it works fine for me, there's a short delay before it'll generate a new pattern, 2 seconds or so. I'm not sure why it wasn't working properly for you... is the latest AssetPackage better? It's purely a modification of the Example provided with the tutorial you watched

If it was with keys on a keyboard though, I don't see any premade playmaker system event globals for input keys, to reduce the amount of time laying out button actions when a cube moves.

You can have a state checking for the key input, and when one occurs send off a global event to the required object.

Plus, what would that mean for coding when it comes to input, I was curious because I don't see coding tutorials on youtube regarding unity3d simon says gameplay? Or do you develop games only with playmaker?

Playmaker can talk to external scripts and vice-versa. There's information on how this works in the Playmaker Manual

EDIT: If it isn't working on yours... it could be the global event isn't being exported with the scene... I did say I was new to the exporting process =/ Sorry. Simple enough to fix on your end. Look for the "Send Event Action" in the "Show item" State. Give it an event from your global event list. Next, Go to your template (click on a cube in the heirarchy list and you'll get the option to edit the template in the FSM window) and add "global transition" to the "Start Move" State.
https://imgur.com/qsKSgLI
« Last Edit: February 19, 2016, 10:05:43 PM by Chizzler »

coffeeANDsoda

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
Re: Simon Says with blocks ArrayMaker issue.
« Reply #13 on: February 20, 2016, 12:41:01 PM »

Playmaker can talk to external scripts and vice-versa. There's information on how this works in the Playmaker Manual

Do you know what category or page it is on in the Manual? Don't understand where exactly the page is in regards to custom coded c# scripts communicating with other actions.

« Last Edit: February 20, 2016, 12:46:25 PM by coffeeANDsoda »

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile