Piecewise functions in blueprints

I know what I want to do in my head, but I don’t know how to get it to work on blueprint.

is what I am thinking: F(x) = {If x>0, then move that many units right.
{If x=0, then character is dead.
{If x<0, then move that many units left.

Separate idea I am working on for an item that instantly changes direction of character without lose of speed in new direction.

For item that has character’s speed become negative (i.e. go left instead of right): F(x) = {If x>0, then -x
{If x<0, then x
For the opposite I was thinking: F(x) = {If x>0, then x
{ If x>0, then |x|

If I have not made myself clear I am more than happy to try and clarify anything that doesn’t make sense. I am just having problems translating the math I think in into the new language of blueprint I am trying to learn.

While typing this I have an idea I am going to test out. If it works I will update. If not, then I will still need your help.

So what’s your actual problem?

  • If statements in blueprints are done by using the branch node and plugging the respective condition in.
  • The death of your character can be implemented in various ways.
  • How is your character moving? Does moving right just means incrementing its x or y coordinate or does the rotation of your character needs to be taken into account?

So you just mean x -> -|x|. You can do this by using a get node to your x variables, plugging it into a absolute (abs) node, multiplying this by -1 and plugging the result into a set node for your x variable (or into a condition node, however you want this).

I assume you forgot a minus? If so this is nothing but the previous without the multiplication with -1.

To clarify the problem I am having is I know the math and logic in my head, but I don’t know what nodes to use. I am VERY new to blueprints. I have watched a tutorial or two, but I am still learning the language. That is I know what I want to say in English/math, but I don’t know how to say it to Unreal and have it understand me. I don’t know how to set functions up like a math problem because of my lack of knowledge. I wouldn’t mind a hint or two just telling me which nodes to use, but not how to use them. This way I can experiment and learn on my own, but I also wouldn’t turn down a clear straight forward answer. Either way I hope this makes my problem clear.

TL;DR: Unreal and I don’t quite speak the same language :frowning:

The right click context menu is your friend . You can type anything you want into that, and the results tend to be OK. Also, you can try using the math expression nodes.

This is how this could work within the TopDown template. It won’t in the FirstPerson template because the controller is rotated instead of the actor there. I don’t know about others. Using the SetActorLocation node is probably not the best in your case. This is definitely not the shortest approach, but when you have programming experience or want to try it at some point this is pretty close how you would solve something there.

This is what I came up with after rereading what others have said. I know it is very sloppy, especially after looking at your reply. I am having the issue when I get the speed below 0, the character just turns around and stops. I will look over what you have and what I have and see work out what I have done wrong.