x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.13
Tags:
more ▼

asked Dec 31 '16 at 02:06 PM in Blueprint Scripting

avatar image

yerai97
8 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Dec 31 '16 at 03:29 PM

avatar image

RadiantWings
66 14 15 19

avatar image yerai97 Jan 03 '17 at 10:53 AM

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.

avatar image RadiantWings Jan 03 '17 at 03:22 PM

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

alt text

alt text

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.

untitled.png (213.3 kB)
untitled1.png (230.5 kB)
avatar image SanVj May 01 '18 at 12:12 PM

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

alt text

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?

avatar image yerai97 Jan 04 '17 at 02:57 PM

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:

alt text

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

movement.png (187.4 kB)
avatar image RadiantWings Jan 04 '17 at 04:36 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question