What is the best way to make a Blueprint for a character tilt meter?

I am looking at making a ‘tilt meter’ that will be able to monitor the angle of tilt from the vertical of a character’s spine over the length of an animation. So I have made some videos of a person doing some Tai Chi, and the idea is to give them some feedback. One basic principle is to keep the body upright. I have generated some animations from two videos, one with leaning and one without. I need to be able to analyse these animations in-game so that if the character leans forward past a certain threshold, this triggers an event such as a door being locked, and they can’t move to the next level. If they are not leaning, then no problem; they can go through. It’s a prototype at this stage, so I need to get the fail working and then the pass to trigger the door to unlock. A further aspect would be some sort of visual feedback maybe a radial dial or something similar to a barometer or clockface to show the actual tilt angle from one tick to the next and maybe a sort of high tide marker that shows their worst case so far and a line that shows how close they are to the fail angle.

What is the best way to do it with a blueprint?
Should I edit the character’s animation blueprint?

Here’s what I am thinking, but I am not a coder, so any advice is appreciated.

  1. The first idea was to have two points on the floor, one directly below the tailbone and one directly below the neck, if they coincide this means the spine is vertical, if the neck point creeps forwards of the tailbone point this means they are leaning and if this gets beyond a certain distance then this triggers the fail event and the door is locked. The advantage of this idea is that it has a certain visual quality; the points could be attached to some object or texture and give the player some visual feedback during the animation. How to actually do it, though? What is the mechanism? It teaches them to think about their hips being always underneath their shoulders to maintain their balance. The disadvantage is it seems relatively complex, there’s probably a simpler way.
  2. Then I started thinking about the angle of bones and triggers. If I could attach some bone or null or other object to the tailbone (spine1) and had a collision box on the floor, say if the bone were orientated forward, then if they leaned too far, it would at some point intersect and overlap the box to trigger the event. Then I thought this shouldn’t be visible because it would look a bit weird, so perhaps make the same thing internally for the model and on a smaller scale so it is not visible to the player.
  3. I started thinking about maybe using the similar principle to 2 above but with a line trace, so somehow if I can attach the line trace to the spine1 bone then if it intersects some object like the floor at some point this would trigger the event. Can a line trace be attached to an object like this so it moves with the rotation of the bone? Instead of spine 1 on these last two ideas, maybe add a helper bone that is attached to the tailbone at one end and the neck at the other to get the rotation value, i.e., the pitch of the spine. I am guessing this interaction will have to be a tick event, so it is constantly measuring the amount of tilt.
  4. Perhaps all this talk of helper bones and triggers is overthinking, and I can just generate the data of the rotation or pitch of the tailbone and work from that. If it gets past a certain amount, this triggers the fail event. Once I get this to work, I can iterate some further methods that are more visual as tutorials; the main thing is to get the ‘tilt meter’ to work.

Any thoughts on the matter are greatly appreciated. I am an animator and am just starting to learn about blueprints, so this will be a valuable exercise for me and a core aspect of my current project.

How about this, angle between two bones in degrees:

When it comes to visualisation, that’s really up to you, you could have a Radial Slider and set its value:

Thank you, I’ll give that a go.

So here’s what I got so far, but something’s not right.

The needle is twitching but it’s nothing like the character’s movement.

In fact, I noticed that even if I pause the animation, the needle still twitches, so it’s hooked up to something but just not measuring the movements of the spine.

Looking at the animation it might work just as well from reading the rotation of the pelvis.

What’s missing?

Also, how can I enable the dial and the numerical readout at the same time?

Pretty much everything.

  • most importantly, the script I suggested is in no way associated with the dial, it just sits there and does nothing
  • no clue where tilt variable comes from, we can’t see it being set
  • you’ve connected tick delta time as the angle? Delta Time is the time that passes between frames
  • avoid using Delay with Tick

  • reference the widget
  • inside the widget, create a custom event that takes a float attribute
  • use the suggested script on tick and pass the float angle to the custom event above using the ref from the 1st bullet point

Thank you very much for your help, I really appreciate it.

I did a print string on your code and it appeared to be generating numbers so I guessed it was reading something and generating an output when the animation was running but on reflection I guess not.

I’m new to coding, mostly being from an artistic background, so at this stage I’m struggling with what may seem to you to be basic principles. So is there any chance you can walk me through the above in simple step-by-step terms?

I’m working with tutorials but often they show you how to do something but don’t really explain what’s happening or why. Being an artist I’m mostly used to looking at things so if you could show me how it looks in the blue print and explain what your suggested improvements are doing that would be a great help. I really want to get this working but I also need to understand how it works so I can learn.

1 Like

I’m working on a prototype.

I did the Unreal Fellowship tutorial on Blueprints. The example they give is making two doors which are triggered by a keypress to open and close and can be locked by triggering a button, also with a keypress. When the button is pressed a light also changes colour to indicate if a door is locked or not.

I have motion-captured animations that players can learn Tai Chi moves from; they watch them and copy the moves. Then they video themselves and upload the video. We process the video on the Quickmagic.ai website and an Unreal 4 animation is generated. The player can then watch their animation in the game but more importantly we can get data from it.

So one big problem in learning Tai Chi is leaning, if their video/animation exhibits leaning then we should be able to set a limit and if they pass that limit they are locked in to the level until they submit a video without leaning. I have filmed two sample videos one with leaning one without and generated the animations. I also made an exit to the level with a door that can be locked or unlocked, a rock rolls back to reveal a passageway.

The tilt meter is what ties it all together.

I made the menu from a tutorial so I am getting the hang of using blueprints and I also did a Codecademy course on C++ so I have a handle on some of the basic ideas but still got a way to go.

Right click the return value pin and promote.

Ok getting there, needle still not moving tho.

This is how it looks so far, all good?

I have a texture of a needle in the designer part of the widget, something I need to do here?

There’s no script that rotates the needle.

Ok so I tried this and the needle appears and moves, no twitching this time.
If I do a print string it seems to be throwing out float numbers between 7 and 14.
It still doesn’t appear to correspond to the spine movements though.
Maybe its reading the wrong axis?
The script reads world space though not actor space.. Just thinking out loud here.
The spine tilt is mainly in the X axis, (pitch).

Ok so just testing out some ideas, I tried restricting the rotation values to the X axis and that gave some much more dramatic results than previously, and they seem to correspond roughly to the mannequin’s movements.

There could be some chatter from the fact that the animation is 30 fps and the tick is probably much higher but less likely to be a multiple of 30. Maybe dampen the needle down somehow?

Anyway I also subtracted a factor of 60 to try to get the needle pointing upright when the model’s spine appeared to be upright.

It looks a lot more like the actual movements now but I’m not sure if the needle movements are actually being driven by the leaning angle, need to test this somehow, thoughts?