LogicBricks

Plugins LogicBricks

Hey Mac !

We're experimenting something with Reign. Since he's not technical at all, I'm handling the thing :p
I've tested several things with the state machine, and I think (suspect) that I can't do what we're trying to do with the bricks, but maybe you can clarify it for me ?

I was trying to make a single button changing a state but from any possible other state. Let me describe a use case :
- Let's say you got three states for a character : PostionA, PositionB, PositionC.
- With a single button (and a single call SwitchState), I would like to call SwitchState : "PositionA" state from either PositionB or PositionC.

The idea behind that would be when you switch state from PositionB or PositionC to trigger an action (ie, in this case, a specific timeline animation) to go to PositionA. But without going through the hastle of handling several buttons, hiding them, showing them, to have different trigger calls.

From StateMachine in LogicBricks, I'm pretty sure it can't be handled natively. (but I may be mistaken)
And he told me that you said IdlePoser could help, but digging inside the plugin I don't see how it would be possible to handle different transitions... but again, I may be mistaken or missing something.

So maybe you can point me in the right direction ?

One note tho ! That would be awesome if we would have a readable value from the StateMachine to gather the state from any external plugin : D
 
Last edited:
I'm trying to figure out how to do something, and a discord member said I might be able to use Counter logic brick to do it but I'm not really following how.

I'd like to have a sphere interact with 2 collision triggers.
I want the one collision trigger to increase the value of a body morph while colliding with the sphere.
I want the other collision trigger to decrease the value of a body morph while colliding with the sphere.
If the ball is touching neither collision trigger I want the body morph value not to change.

So far I have tried doing something like getting the collision trigger to change to the maximum value I want to permit over say, 5 seconds but only be activated while colliding with the sphere. It initially appears to be working, in the sense where if I remove the sphere from colliding, the body morph does stop, but as soon as I touch it back to the collision trigger the morph "jumps" to a further value. So it doesn't make a smooth value change.

I guess basically I want the body morph value to increase or decrease by X amount when the sphere is colliding with the trigger, not be "set" to a certain value over X seconds which only appears to make it change gradually but doesn't actually work.

Can logicbricks help me do this or can I do it with the built in tools?
It's probably best to make a custom plugin. But yes, you could use a Counter brick. Made you a quick example scene:
1647899370752.png

  1. Two CollisionTriggers atoms. Each has a Timer brick, plus a UIText atom with "Increase" / "Decrease" so you see where it is.
  2. A UISlider atom with a Counter brick.
  3. The CollisionTriggers enable their Timer in the StartActions, while in the EndActions their Timer is disabled again. In the StartActions I'm also disabling the respective other Timer to make sure only one of them can be active at a time, e.g. when you use multiple objects to trigger the CollisionTriggers or whatever.
  4. The Timer bricks each trigger the counter brick by having it Count UP / DOWN.
  5. The Counter brick is just setup to have 50 steps (the maximum supported) and drives the UISlider value.
  6. Take the blue sphere and move it onto the "Increase" / "Decrease" signs and see the slider for up / down.

Scene attached for download. The obvious problem here is that you have 50 steps, so to get to 5 seconds the Timers trigger only triggers in 0.1 second steps, which is of course very visible and possibly not smooth enough. You may want to try setting up something similar using an AnimationPattern which pause/unpause and set the speed to 1.0 and -1.0 accordingly. That should then be smooth.
 

Attachments

  • CounterExample.json
    22.9 KB · Views: 0
Hey Mac !

We're experimenting something with Reign. Since he's not technical at all, I'm handling the thing :p
I've tested several things with the state machine, and I think (suspect) that I can't do what we're trying to do with the bricks, but maybe you can clarify it for me ?

I was trying to make a single button changing a state but from any possible other state. Let me describe a use case :
- Let's say you got three states for a character : PostionA, PositionB, PositionC.
- With a single button (and a single call SwitchState), I would like to call SwitchState : "PositionA" state from either PositionB or PositionC.

The idea behind that would be when you switch state from PositionB or PositionC to trigger an action (ie, in this case, a specific timeline animation) to go to PositionA. But without going through the hastle of handling several buttons, hiding them, showing them, to have different trigger calls.

From StateMachine in LogicBricks, I'm pretty sure it can't be handled natively. (but I may be mistaken)
And he told me that you said IdlePoser could help, but digging inside the plugin I don't see how it would be possible to handle different transitions... but again, I may be mistaken or missing something.

So maybe you can point me in the right direction ?

One note tho ! That would be awesome if we would have a readable value from the StateMachine to gather the state from any external plugin : D
Maybe just using the StateMachine brick is enough. I would recommend trying a setup like this:

You have Main-States (yellow) for each of your position, which trigger a Timeline animation and have it loop indefinitely. Then you have Transitions-States (white), which are also just States, but trigger a Timeline transition animation and wait for it to finish (using TriggerSync). LogicBricks StateMachine does not make a difference between these, its just the context you assign to them. Some of those Transition-States you would then duplicate, with the only difference being the next State they go to. The Duplicate button in LogicBricks StateMachine should be helpful there.
Make sure to watch the part in the StateMachine tutorial about the MultipleChoice system. That's where you hook in the SpeechRecognition, Buttons or whatever you want to use to make the player decide where to go. However, you may have trouble if you need more than 6 Main-States, since MultipleChoice doesn't support more than 6 choices at a time. Possibly you can work with not having all options available all the time, but in any case it get's more complicated.
1647900790205.png


IdlePoser may help for more complex setups because it supports those Intermediate States and it can automatically (recursively) search all the Main-States you can reach in the graph. In the end IdlePoser is also just a StateMachine, just with more features. So you essentially can tell it to go to "Position A" and it will figure out through which Intermediate States you need to go. Probably each Main-State needs its duplicate IntermediateState. Since it supports triggers, you can have it control Timeline instead of using IdlePoser directly for animation. Check the IdlePoser tutorial, section "Path Search" for details on how Intermediate States work. Note that the tutorial is ages old and a bit outdated.
 
Thank you very much for this detailed answer Mac!

I'm gonna test out a basic draft with IdlePoser. If I have any trouble I'll hit you up ;]
 
I know this might not be well received now, but for someone else looking for a solution for this same issue, the workflow outlined by MacGruber is simplified a lot by using a fork of IdlePoser, which is called AnimationPoser and up in the hub. AnimationPoser is a single plugin that has both IdlePoser and LogicBricks capabilities. What is more important, it has a Messaging system: you can use "SendMessage" triggers to send messages to the plugin and the plugin can be set up so that these messages lead to different results depending on which state the character is currently in.

This feature GREATLY reduces the number of states, transitions and triggers that you need to set up. It also doesn't have the 6 choice limitation from State Machine. AnimationPoser is aimed at being a self-reliant animation plugin, but it can also be used as a generic state machine that simply stores triggers to be called according to a given logic. As a generic state machine, it is more powerful than the LogicBricks' StateMachine, and you can run an unlimited number of state machines in parallel by using a single instance of the plugin.
 
"I was trying to make a single button changing a state but from any possible other state. Let me describe a use case :
- Let's say you got three states for a character : PostionA, PositionB, PositionC.
- With a single button (and a single call SwitchState), I would like to call SwitchState : "PositionA" state from either PositionB or PositionC."

In this particular case, you could set up three states in animation poser: PositionA, PositionB and PositionC. Then, define a message for each position, but all with the same message string, say, "Go back".

The "SwitchState" trigger was substituted by the "SendMessage" trigger in AnimationPoser for this exact reason. When a message (say, "Go Back") is sent to the plugin, it activates a different transition depending on whether the plugin is in PositionA, positionB or PositionC, and this is all defined in the Messages tab. You can then define triggers in the triggers tab to switch the Timeline animations from there.

Sorry if that's not a good place for writing this but I thought it was nice to present the solution to a problem I myself had to solve just 2 weeks ago. MacGruber stated above that "It's probably best to make a custom plugin". So, for someone looking for a solution, the custom plugin is there.
 
@MacGruber Thank you for the lead, your post made me understand that I actually need two transitions in IdlePoser to handle In/Out situations (or the trigger wasn't sent). It works pretty nicely : )
 
@MacGruber Thank you for the lead, your post made me understand that I actually need two transitions in IdlePoser to handle In/Out situations (or the trigger wasn't sent). It works pretty nicely : )

Yes! IdlePoser for this usecase is actually the same as AnimationPoser right now. There is no advantage of one over the other, since AnimationPoser starts to differ when there are multiple layers or multiple animations. For a simple usecase with 3 states it works exactly the same. I was thinking about the StateMachine, but IdlePoser does do the trick.
 
@MacGruber Really love SequenceChoice, very useful, thank you very much!
Do you have plans to add PreviousChoice trigger to it? That would be awesome! (y)
 
Hi, RandomSoundFromAB doesn't work if use this AI Shoujo asset bundle
You got to talk to the author of that (which would be @Chiefton). It's using the wrong format for LogicBricks. Seems the sounds aren't added to the AssetBundle as "assets", just a dependencies for a bunch of prefabs. That of course makes it work with just using a CustomUnityAsset atom...but LogicBricks needs it differently ;)
The alternative is of course to extract the sounds (or get them from the source) and package them properly yourself. Although license issues might apply, haven't checked.
 
You got to talk to the author of that (which would be @Chiefton). It's using the wrong format for LogicBricks. Seems the sounds aren't added to the AssetBundle as "assets", just a dependencies for a bunch of prefabs. That of course makes it work with just using a CustomUnityAsset atom...but LogicBricks needs it differently ;)
The alternative is of course to extract the sounds (or get them from the source) and package them properly yourself. Although license issues might apply, haven't checked.
Got it, thank you
 
Hi, @MacGruber
I write this CustomUnityAssetLoad.cs to handle the CUA loaded/cleared events (like EventSceneLoad.cs, and using MacGruber_Utils.cs), think you might be interested in this. :)
 

Attachments

  • CustomUnityAssetLoad.cs
    4.4 KB · Views: 0
I'm using the SequenceMachine a lot to set poses, speechbubbles and camera angles with each State.

When I have more than 50 states, it starts getting tedious to work with. E.g. I want to insert a state between State 25 and 26 or if I want to move around a state to a new position. Do you see any way to improve the UI, so that it's easier to manage a large amount of States? The slider is hard to work with at this point.

Thanks for your input. I'm even considering if I should try my hand at extending your UI, but I haven't touched VAM development at all.
 
I'm using the SequenceMachine a lot to set poses, speechbubbles and camera angles with each State.

When I have more than 50 states, it starts getting tedious to work with. E.g. I want to insert a state between State 25 and 26 or if I want to move around a state to a new position. Do you see any way to improve the UI, so that it's easier to manage a large amount of States? The slider is hard to work with at this point.

Thanks for your input. I'm even considering if I should try my hand at extending your UI, but I haven't touched VAM development at all.
The assumption I made during design was that when anything gets too large to handle, you would just use multiple cascading SequenceMachine/StateMachine. In your case a "Master SequenceMachine", that sequences the other SequenceMachines? That allows you to basically manage ANY amount of states while still being able to test each Sub-SequenceMachine individually, etc.

Other than that, you can also of course edit the scene JSON by hand move a State 25.5 to the position you want it at. (Make sure you make a backup copy before manually editing the JSON)
 
MacGruber updated LogicBricks with a new update entry:

Version 13 (free)

Probably very random seeming list of changes....but it all makes sense! I need them for an upcoming minor scene release ;)

Changelog for LogicBricks v13
  • New RandomAnimation brick. Simple plugin provides a random motion within a sphere for the main control of an atom. This is intended to be used as anchor for IdlePoser states, for example providing some small continuous idle motion for a...

Read the rest of this update entry...
 
Is there any way to get the Logic Brick OnSceneLoad to only trigger ONCE?

Basically what I have set up is a standalone scene which just contains the ToySerialController plugin as well as a custom made hand-mounted control panel I made for it.

I want to have this scene merge-load into every scene I load, so I thought the SceneLoad logic brick would be perfect.

The problem is that this SceneLoad plugin triggers every time from the merge-load as well, so I end up with an infinite loop scene merge-load with no way to disable your plugin other than doing it manually since it is loaded as a Session Plugin, which cannot be controlled via Triggers.
 
The problem is that this SceneLoad plugin triggers every time from the merge-load as well, so I end up with an infinite loop scene merge-load with no way to disable your plugin other than doing it manually since it is loaded as a Session Plugin, which cannot be controlled via Triggers.
Hm, I had not thought of that use case. Possibly you could have the SceneLoad plugin trigger a RelayOnce (also as session plugin) which then does your stuff?
 
MacGruber updated LogicBricks with a new update entry:

Version 14

Version 14 adds the new SoundFromAB brick and other improvements around the topic of handling large amounts of sounds.

So, pick your favorite text-to-speech AI out there and have it generate your voices. Put them into an AssetBundle. Then enable VaM's new build-in lip-sync and use LogicBricks to play your voices. Having hundreds of voice lines in a scene isn't an issue anymore!

Changelog for LogicBricks v14
  • SoundFromAB: New brick that...

Read the rest of this update entry...
 
@MacGruber I am sorry to bother you with this again, but if you ever run out of plugin ideas and if you have time, an update to SequenceChoice plugin so that it could trigger next choice and trigger previous choice would be greatly appreciated! :cry:
 
@MacGruber I am sorry to bother you with this again, but if you ever run out of plugin ideas and if you have time, an update to SequenceChoice plugin so that it could trigger next choice and trigger previous choice would be greatly appreciated! :cry:
You can use a StateMachine in Advanced-Mode, using the MultipleChoice triggers.
 

Similar threads

Back
Top Bottom