playMaker

Author Topic: Best way to combine custom C# & Animations with Playmaker  (Read 1894 times)

PET

  • Full Member
  • ***
  • Posts: 139
    • GamerPET
Best way to combine custom C# & Animations with Playmaker
« on: September 25, 2023, 06:17:46 PM »
Hey guys, long time no see!

I'm implementing (for fun) a board game in Unity.
This is a way for me to learn C#, re-learn Unity, etc.

Since board games are very State based I decided to use Playmaker to track states. Each state will call a Method that I wrote. I'm still at the beginning where I'm setting up the "Game Board".

Things generally work, but I'm getting stuck with some "best practices".

For example I have a method that will "randomly pick a game object and move it to another game object". When that happens I want to have an animation. I'm using DOTweenPro for that.

If I am to just call this Method using Playmaker, he will just do the call and then he will move on, he will not wait for the animations to complete.

So basically my core problem is now to combine Code + Animations + Playmaker Waiting before continuing.

I used ChatGPT to get some suggestions and basically I have something like this:

- Coroutine DrawClone (this will call another Coroutine DrawClonesCoroutine)
- DrawClonesCoroutine
- Playmaker Action that calls "DrawClone". I also have another Coroutine here.

This way my Playmaker Action will wait for his Coroutine to finish.
I am a bit confused about this whole thing... but the thing is that it works. The initial DrawClone wasn't a Coroutine, but ChatGPT made me make that one a Coroutine probably so the Playmaker Action knows when things finish. I think :))

So my main problem now is...

What is the best way to optimize everything?

I'm thinking that there will be a lot of things I want to animate and I would really like Playmaker to just WAIT for things to complete, or wait for some kind of Event.

I used a Coroutine here and not a "Event" because I can't be sure what FSM is active to receive the Event. This FSM is the GameSetup fsm, but I will use the same DrawClone Action with another FSM for example.

Any suggestions?

Thanks <3

Technical Game Designer
www.GamerPET.com

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Best way to combine custom C# & Animations with Playmaker
« Reply #1 on: September 26, 2023, 12:28:38 PM »
Hi.
With the default Tween action there is a "finish event" to see when a tween is finished.

for dotween there is a PM action package on the Asset store that I saw :
https://assetstore.unity.com/packages/tools/visual-scripting/playmaker-actions-for-dotween-by-doozy-49222

But if you can code a bit you should also be able to make a custom action for what you need. instead of using the Call Method action.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames

PET

  • Full Member
  • ***
  • Posts: 139
    • GamerPET
Re: Best way to combine custom C# & Animations with Playmaker
« Reply #3 on: September 26, 2023, 05:29:25 PM »
Those Actions from the asset store seem to be a bit obsolete.

Generally speaking, what is the best way to do this kind of interaction?

Method -> Animations -> FSM

I'm curious in a theory kind of way so I can learn to do things optimally.
Right now it's a bit weird because my PM Action Starts a Coroutine, calling a Method that is also a Coroutine that calls another Coroutine that does the animation. Things work fine... but I'm not sure if this is the right way, or what is the right way :))

Like I have other functions that do things like "Adding Cubes". They work fine logically, but if I want to add a bit of polish and do some kind of small animation... how?

Thanks
Technical Game Designer
www.GamerPET.com