I’m trying to create a hierarchical state machine, but don’t understand how to transition to a superstate

I have a CharacterController that implements a StateMachine that uses a number of states and transitions. The StateMachine checks for a valid transition to a new state at the start of every frame, and either moves to a new state or continues ticking the current state. Here is a brief example of all of this working together:

public class CharacterController : MonoBehaviour {     public StateMachine { get; private set; }           private void Awake()     {         InitializeStateMachine();     }      private void Update()     {         StateMachine.Tick(); // Checks for valid transitions, and then sets and/or ticks the appropriate state     }      private void InitializeStateMachine()     {         StateMachine = new StateMachine();          // Create states         var idleState = new IdleState(this);         var walkState = new WalkState(this);         var jumpState = new JumpState(this);          // Add some transitions         Func<bool> idleToWalk() => () => IsGrounded && velocity.x != 0;         Func<bool> idleToJump() => () => IsGrounded && Input.GetKeyDown(Keycode.Space);                                     // From       To       Condition         StateMachine.AddTransition(idleState, walkState, idleToWalk());         StateMachine.AddTransition(idleState, jumpState, idleToJump());     } } 

I really like this implementation because the states and the StateMachine are decoupled; only the "motor" class knows about both of these things, which makes it very easy for me to keep my code clean. Specifically, I like that the individual states don’t have state-switching code in them; then, if I want to make changes to how transitions between certain states occur, I have all of that code in one place (the InitializeStateMachine method, or I can add transitions in specific places later).

However, as my project grows I’m running into an issue where I’m having to create many transitions to states that share similar functionality. For example, the idle and walk states only work if my controller is grounded, so if I have a fall state then I need to make transitions from the fall state to every possible grounded state:

Func<bool> fallToIdle() => () => IsGrounded && velocity.x == 0; Func<bool> fallToWalk() => () => IsGrounded && velocity.x != 0; Func<bool> fallToSlide() => () => IsGrounded && velocity.x != 0 && Input.GetButtonDown("Slide"); 

It would be nicer if I could simply transition to some kind of generic GroundedState that handles the next steps as needed.

I read that one way to help solve this problem is to create a hierarchical state machine, but, though the concept makes sense to me, I don’t understand how to implement it in the context of my current system.

I assume that I would need to make a GroundedState parent class from which any ground states inherit, but how do I actually make transitions from fall to grounded, and then get from grounded to, for example, walk or slide in a single frame? Would the GroundedState need a reference to the StateMachine class so that it can set the correct substate accordingly?

How to create random interpolated polygon shapes based Mesh in Unity?

I want to generate random Polygon (or maybe I am not using correct term) shapes as Mesh generated randomly and dynamically from script in runtime as shown in the picture attached. enter image description here

I want to use as Mesh Collider based on those procedurally generated shapes, I am using those shapes as to detect Bounds.Contains a certain gameObject’s position. I also want to assign a transparent material to those shapes, that will only be a color though or a diffuse texture with different opacity.

I have seen some tutorials on how to generate mesh from script, but it only helps me if I know the vertices positions exactly and how to adjust the tangents. I am unable to make them randomly generated. If you can help me correct the technical term used for this kind of shapes will also be useful. Or any work done before similar to this in the form of an Asset available on Unity store, or github repository. Or maybe even basic idea on approach how to research it or do it.

How to create a directory template in Unity?

How to create a directory from a template with multiple files in it which are also created from templates?

Right now, I am particularly interested in creating an Assembly directory which uses a user-entered variable ASSEMBLY_NAME, take the project name variable from the settings and would create the following simple file hierarchy:

  • $ {ASSEMBLY_NAME}/
    • $ {PROJECT_NAME}.$ {ASSEMBLY_NAME}.asmdef

where the $ {PROJECT_NAME}.$ {ASSEMBLY_NAME}.asmdef file would contain:

{   "name": "$  {PROJECT_NAME}.$  {ASSEMBLY_NAME}" } 

… but I would also be glad to learn any way to create whatever complex templated hierarchies, like creating a class and a companion test script together at once, create a directory with a "readme" file in it, etc.

I know this is somehow possible, because there is a default Unity UI function which does exactly the same, but for test assemblies only, so it adds extra code in the assembly definition file which I don’t need.

enter image description here

I cannot find anything on this topic apart from answers on how to create/edit a single file templates, e.g.:

  • How do I customise automatically-generated script?
  • https://stackoverflow.com/questions/39461801/unity-add-default-namespace-to-script-template

MSSQL 2012 Update (or create new certificate with same name) that uses Symmetric Key encryption

Super short version of my question:

For a MSSQL 2012 DB is it possible to update the current certificate with a new expiry date and new PW (or create new certificate with same name)? Or some other option I have not thought of that would be quick/easy to implement?

Now the details (there is probably simple answer I am just not able to find online):

We have a SQL 2012 DB and in lower environments (single server only for each) and our production which has failover server (so whatever my solution needs to include the ability to work with primary and failover server).

First two notes:

  1. The key/certificate I know is outdated/not best way and we are working on redesiging our encryption.

  2. We are working on upgrading this MS 2012 DB to 2019 soon, but not before I need to make this update/change.

The code for select (but we also do update/inserts) is used like this in SP’s (and also a trigger):

OPEN SYMMETRIC KEY KeyNameHere DECRYPTION BY CERTIFICATE CertificateNameHere        Select DecryptByKey(EncryptedColumn)     From dbo.TableName  CLOSE SYMMETRIC KEY KeyNameHere;  

I thought I had a solution (and using these steps testing it does work):

  1. Backups existing certificate

  2. Creates new certificate (and then back it up)

  3. Updates all SP’s using the certificate to use a new certificate name in code like:

Existing: OPEN SYMMETRIC KEY KeyNameHere DECRYPTION BY CERTIFICATE CertificateNameHere

New: OPEN SYMMETRIC KEY KeyNameHere DECRYPTION BY CERTIFICATE NewCertificateNameHere

  1. Drops old certificate

As I said the above does work in testing on dummy DB but there are a LOT more SP’s than I was told and I can update them all to use new certificate name (as above) but I would prefer to find a way to not have to update all these SP’s code, but I can if needed.

Key question/concern is around the certificate in production (primary and failover servers) and what/how to ensure the update is completed on both and will work if/when a failover occurs.

If there is anything else I am missing or not considering please let me know.

How to create templates for a custom module to show on the front end within my theme?

I’d like to create a simple plugin with a form on the front end which submits the value of 3 fields into a DB table.

For the plugin, I’ve been using this answer: https://wordpress.stackexchange.com/a/162476/77891

What I can’t get working now, is a template.

Within the main plugin file, I’ve added:

add_action( 'gm_virtual_pages', function( $  controller ) {      // first page     $  controller->addPage( new \WEBP\Management\Page( '/custom/page' ) )         ->setTitle( 'My First Custom Page' )         ->setTemplate( 'custom-page-form.php' ); } ); 

And my custom-page-form.php:

<?php  echo "Test Echo";  ?> <p>Test</p> <p>Echo</p>  

The title is being displayed (My First Custom Page). But not my Test Echo. How does a correct / working template file have to look like?

Create an interactive list in a Wolfram notebook that choosing its items make a change in calculations

I have 3 variables. I want to create an interactive list of items in a Wolfram notebook that if I choose each item, functions that are written by myself change the value of the variables and recalculate all the expressions. For example items are a b c and the variables are a1 a2 a3. If I choose item a, I want item a to become equal to b, etc. Then all related calculations should automatically be updated. I was wondering if anyone can help me in creating such a functionality.