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"

How to move square by square, dungeon crawler ?

Hello, i'am French and my english is very poor, sorry ;) I make a dungeon crawler, but coding is hard for me... but I learn fast ;) How to move square by square like a dungeon crawler with blueprint ? thanks for all

Product Version: UE 4.12
Tags:
more ▼

asked Jul 24 '16 at 08:23 AM in Blueprint Scripting

avatar image

bobchocolat
0 2 3 3

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

1 answer: sort voted first

Hi there,

this might help you, and there are lots of discussions to learn from :)

https://answers.unrealengine.com/questions/273704/how-should-i-implement-grid-based-movement.html (there is even a link for template samples to download)

https://forums.unrealengine.com/showthread.php?31267-Noob-needs-help-Moving-Units

hth :) Marooney

more ▼

answered Jul 24 '16 at 11:51 AM

avatar image

Marooney
891 36 8 37

avatar image bobchocolat Jul 24 '16 at 12:27 PM

Thanks Marooney... but it will take me some time to understand how to do it in 3D ... Ideally, I wanted to put a distance of movement for not doing grid ...

avatar image Marooney Jul 24 '16 at 06:49 PM

When you have a top-down view with square by square movement then you will have grid movement :) Or do want to create a side-scroller?

avatar image bobchocolat Aug 01 '16 at 02:14 PM

Do you know dungeon master or Grimrock? you would not think .... The view is that of a fps and the displacement is by square ... or by distance (eg 150u) And I see that everyone says it is easy or suggests, the sort requires blah but nobody knows exactly how to do ... Also I found 2 different examples approaching what I want with cubeblocks and GridMove and it is far from easy after studies of BP ...;) No I think the simplicity displacements by distance will be simpler ... but may be I am wrong I am currently testing ... Thanksss

avatar image Marooney Aug 01 '16 at 04:31 PM

I just watched a youtube video of that game. I have played similar games decades ago.

How do you create your dungeon? If you use cube blocks then you need to arrange them. And in the end you will arrange them as a grid anyway. So you will have grid movement. Which is your distance movement.

What is so wrong with the first sample i gave you? It works for FirstPerson View as well. (https://answers.unrealengine.com/questions/273704/how-should-i-implement-grid-based-movement.html)

The first screenshot shows you how to check if there is a wall:

You press forward once, the look direction of the character tells you which direction you want to move the character within your map. And then you just need to implement the screenshot. If the hit result is false (no wall or closed door) then you can execute the second screenshot.

The second screenshot shows you how to move the Character. GridSize 100 where 100/2 is the middle position of the cube. And the Timeline handles correct movement over time to the target distance.

Just try this on a simple plane, you will have your "distance" movement like that in any direction you look with your character. And you will get the Grid-Movement for your cube blocks by snapping rotation to 90 degrees (like you see in the Grimrock game).

Hope that helps :)

avatar image Marooney Aug 01 '16 at 04:46 PM

"And I see that everyone says it is easy or suggests, the sort requires blah but nobody knows exactly how to do" Once you are able to handle others suggestions and solutions, you will be happy that people know what they are talking about.

And to be able to understand what people say and to be able to extrapolate information of other tutorials, I highly recommend you to watch as many videos from the following playlist as possible. Short and compact basic knowledge. If you think you do not need them, you will run straight into issues by not knowing things. People just lead you the way, and the playlist shows you how to walk :)

https://www.youtube.com/playlist?list=PLZlv_N0_O1gaCL2XjKluO7N2Pmmw9pvhE

avatar image bobchocolat Aug 01 '16 at 04:58 PM

I watch videos for over a week, but my English is limited, and my brain too ;) The worst is that I do not want grids or other things to learn too long, I just want to give away the forward, backward, strafe left and rotation etc ... When I see 3/4 nodes for movements default and complexity of other stuff with grid, I told myself that it's not normal to make 8 pages of blueprints ;) In any thank you again;)

avatar image Marooney Aug 01 '16 at 07:41 PM

No need to be afraid of these tutorials :) It is really just about these 2 screenshots mentioned there :) I have put this together for you now. So this sample solves all you are asking for:

For this sample you need to create a new FirstPerson Template Project.

Within the FirstPersonCharacter Blueprint:

Add these two events:

  • Move takes the direction you want to move to. Calculates Start and End location. Does a LineTrace towards the destination. And if nothing gets hit, it starts the Timeline which does the movement. DoOnce makes sure the timeline does not start over again during movement.

  • Rotation is similar but does not need the LineTrace. Rotation is handled by the PlayerController so you need to set the values there.

Interpolation is done by the Alpha-value which is the percentage between the fixed Start and End values.

alt text TimeLine Curve for Movement and Rotation Timelines. You can adjust the Curve as you wish but keep the value between 0 and 1: alt text

And now you just need to handle Input. Replace some existing nodes within the Blueprint.

Movement - where you need to get the direction vector: alt text

Rotation - where you need the YAW direction. I've put a mouse input leeway in, to avoid rotation on a single mouse input: alt text

Have fun :) It works on my side, so if you have any issues, feel free to ask :)

And if this solution works for you, please click the accept answer button on the left side of the answer :) The answer will turn green and the Question will be marked as [RESOLVED] for everyone. Thx :)

avatar image Marooney Aug 01 '16 at 07:52 PM

Btw. Implement the Movement at first and play around with. And after that the Rotation. That makes it easier for you to understand what is happening. Because then you will realize, this is already the Grid-Movement :)

avatar image Marooney Aug 01 '16 at 09:23 PM

Oh, and if you move while the character is rotating, you will have a wrong direction (leaving the grid). Just avoid such input for now and you can fix that pretty easy later on before someone else plays your game. (You can use a Gate-Node in the Move-Event that gets closed while rotating)

avatar image bobchocolat Aug 04 '16 at 09:44 AM

Hello my savior ... or anyone;) After 2 days: First day I understood (+ or -) your code and have applied for my keys ... Hooray;) Second day, I try to stop the rotation during movement (move_event) with gates ... Failed ... Same with the keyboard and I have no ideas ... I found a post but it does not work for me... or I've done wrong ... https://answers.unrealengine.com/questions/349979/how-do-i-stop-the-input-of-other-directional-keys.html Otherwise, I also have a slight problem with collisions ... When I click many times a key movement, I cross the walls ... And one last thing about the movements ... That with the right mouse click to bullback with both axes and disable the movements and rotations ... a track? (Surely input_active / Deactive but for the right click ....) Well thank you in advance ... or not ;) PS: I post the imgs for the next...

avatar image Marooney Aug 04 '16 at 11:01 AM

Hey, my solution for your problem was just one of a thousands ways to solve something. This was the easiest and shortest one with ThirdPerson Template I figured out for you. Because you don't have any dungeon right now. And you don't want to face your dungeon Grid that explicitly for now.

This is the Gate solution to block the Movement during Rotation. Rotation during Movement is ok, because StartLocation and EndLocation are calculated at the beginning of the movement. alt text

You only face your collision Problem on the ThirdPersonExample Map which is not set up for your movement "Distances" (No Grid and inappropriate obstacles). You can still set the "Sweep" option at SetActorLocation that handles collision for you. But in your dungeon you will not have a wall or door in the middle/center of your "Cube" anyway, just on the sides. And this collision is already handled by LineTrace.

In your dungeon you need to set your Character into the center of your first tile/cube. If your character collides for any reason, it will be off grid for further movement. So you don't want to use the sweep option.

disablemovement.jpg (132.0 kB)
avatar image bobchocolat Aug 04 '16 at 12:00 PM

Thank you, but it does not work ;) What I think by my tests, in my opinion because the door opens a time T, and, going the 2 flux (shown in graph_event) I think the only way is to completely cut the key / flow while the other is execute ... I glimpse myself as the character "steals" in a vacuum, so I quickly click the movement... For now, I add a delay at the end of the event that corrects collisions and levitation but it slowed the gameplay :( Again thank you very much even if it is not the point ;)

avatar image bobchocolat Aug 05 '16 at 07:47 AM

After several tests, I understood that the curves lerp was the problem ... If the last point of the curve is equal to the length, so it creates a lag with the full accomplishment of the movement because each time, from 0.1 the curve is not fulfilled .. (regardless of the length: 0.15 to 0.14 for the rotation and last point, works very well) In fact, I think the gate was not working because it was a lag of rotation, while the gate works perfectly !!! This also caused collisions problems ... I still have two problems: 1 major: The character does not fall as the buttons are pressed ... 1 minor: When collision sound is played several times at the same time ... Thank you

avatar image bobchocolat Aug 04 '16 at 09:53 AM

For the next with the same problem but we must first make the two events (move and rotate) post by Marooney ...

(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