Hi, I made a blueprint for turning the head, but Now I wanted to make something happen depending on where I am looking at.

SO I made a blueprint that made the character look to the left when pressed “A”, to the right when pressed “D”, and back when pressed “S”. Now I wanted to make a action happen with “E” when I look to the left of the starting view, and something else happen when I look to the right, and something else happen when I look back.
This is the blueprint:

191fa5fd54f6a5f0baa13515183d35086cf10be0_2_690x422.png

If you can help, thank you.

Google “blueprint enumeration” and “switch on enumeration unreal blueprint”.

you can also switch on ints and bools but for a beginner i think you’ll have easier time understanding using an enumerator.

matthew wadstein on youtube is the go-to guy for quick tutorials covering the basics like this.

I am sory but i tryed to find it, and i found nothing

Hey @xinox096,

Here is a great resource you can to learn more about blueprint enumeration.

1 Like

I am not understanding on how an enumeratio can help me in my problem. If someone can explainbit to me, I would be gratfull

Hey @xinox096,

Essentially the suggestions works like this. You have, I am assuming, 4 states, forward, backward, right, and left. You would use an enumeration to keep track of the current state (for example when you look back). At that point you would use a switch to determine what the next action would be based on your direction. Here is a rudimentary example of what that may look like when getting started:

UnrealEditor_tQbElJ9f2t

How do the enumerations know the actual directions?

Hey @xinox096,

You can create a variable of your Enum type and set it at the end of your direction change, then get that variable on pressing E.

UnrealEditor_AHZtyBMJVi

That makes sense thanks. But how do I make the door open and close?

an enumerator is just a number that has a name associated with it.

name is just so that you can easily read it, instead of having to remember that 1 = left, 2 = right, etc.

To make a door open is really worth making a separate thread because it is a separate question from the title here.

it is good to only discuss just one small problem per thread that way people searching for answers in the future can easily find them.

In fact, I bet if you search “how to open door” you’ll probably find a ton of answers already.

1 Like

Hey @xinox096,

Just to make sure, was the enum above the solution to the original question you were looking to solve?

@Quetzalcodename Yes kinda, i think that will help me, but I am still not shure how the game knows that forward means look forward (I am sorry, i disnt test it yest in my game), so if you could explain or send a video that explins that, it would help

@BIGTIMEMASTER I was looking at the code, and I notice that ehen you said “W” is 000000, it meant forward. But i dont turn forward pressing “W”, I can only use “A”, “D”, and “S”


This is the code that I have

Do you mean that each time you press D, the character always turns right 90 degrees, and each time you press A, character always turns left 90 degrees?

and then if you press W, character goes forward whichever way it is currently facing?

if that is the case you don’t want to set an absolute rotation. instead, you want to get the current world rotation and then add 90 or -90 to the yaw, and then use the result of that to set new world rotation.

dont have unreal open now, will show some blueprint code later if you still need it.

Yes, when you press “A”, it turns -90 (left) and “D” 90 (right). There is no W. How would I make that?

Hey @xinox096,

Checking in, was the above the solution you were looking for?

Sorry, I couldn’t find the “Set Control Rotation” Blueprint. How does that work? And i couldnt find the Directions variable.

Set control rotation was only used as an example here.

whatever actor you are trying to rotate should be your target. You can use “Set Actor Rotation” or search for “set world rotation” if you are trying to rotate a component within an actor.

control rotation has to do with the player controller - you’ll need to read up on that to understand it, it is not possible to explain in just a few words.

I used a literal float as placeholder for where you would use some variable to determine how much to rotate by.

To be frank, you really ought to follow some beginner tutorials (check out the learn section on the left tab, tons of great tutorials to choose from). These questions you are asking will be answered 10,000x faster if you go through some tutorials, rather than ask one question at a time here.