Control Movement with Triggers

Hey everyone,

I’m trying to change the character movement depending the trigger which it passes, that is, if the character passes through a trigger it turn to the right and if the character passes through another trigger that it turn to the left.

I’m new to unreal engine 4 and I don’t know how to do this with blueprints.

Thanks in Advance!

You can try and make a Blueprint with a Box Trigger Component and then make a OnComponentBeginOverlap Event which takes the overlapping player and rotates them 90 degrees to the left or right.

To get you started, go to your Content Browser, right click to open a a menu, go to the Create Basic Asset section and select Blueprint Class. Then you’ll see a menu asking what you want the parent class of your blueprint to be. Pick Actor.

After that, name your asset and double click it to enter the Blueprint editor. You’ll be greeted with a window with three tabs within it; Viewport, Construction Script, and Event Graph. You’ll be interested in the first and third tab for the most part. Anyways, go to the Add Component drop down in the top left corner, click on it, and scroll down till you see Box Collision and click on that.

You should now have a Box Collision from which you can wire up an OnComponentBeginOverlap event to do the character rotation stuff earlier.

It works!! Thank you so much. It works usefull for me but I need something else.

I want to simulate the movement keys when the character is on the trigger. While the character is on the trigger it turn like if you press the movement key, I pretend to use a “WhileLoop” to move the character while it is on the trigger.

Thanks for use your time helping us.

No problem! I’m always happy to help!

As for your other request, let me see if I understand it first. So you want to make it so that when the player presses a key, the character on screen would visibly rotate to face the direction the player wants it to move in?

If that’s what you want, you can try adding a boolean to your character called bIsRotating or something like that. Then you would bind an event to Tick where you would modify the rotation of the character slightly so that it rotates in appropriate position.

I know what I said may be a little confusing so let me coin an example in blueprints

Try and follow the blueprints I’ve given and it should help lead you to your answer. It may not be the best way to do things, so if you find a better way to achieve your goal then by all means go for it.

No, it isn’t that I want.

I want that when the character is on the trigger he moves alone to a direction (left or right). You haven’t to press any key.

This is my movement input character blueprint:

I would like to do the same function that InputAxis MoveRight Event with a trigger but I don’t know how.

Oh okay, sorry about that.

For that you could make a follow up function that can pick a direction (presumably randomly) and then use Add Movement Input in either the left or right direction.

Keep in mind that the InputAxis event and its Axis Value changes in accordance with the input of the player. I’m guessing that what you want will be done automatically so you should probably tie whatever event of function that does what you want to Tick.

I have a similar question. This is my SideScrollerCharacter’s blueprint.

I have added a Boolean variable to check if I can ‘Take Cover’ so that the character won’t be able to enable this action always. The character should be able to take cover only if he reaches the specified box trigger. I have added this box trigger in different blueprint class. How can I set the boolean variable on reaching the box trigger.? Is there any better suggestion?