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"

Speed and pathing in top-down template (blueprints)

Hi all, This is gonna be my first attempt to play with blueprint scripting and I'm running into a wall when trying to create a few modifications to my game, which is currently just the top-down template.

First: I'm trying to create a dash / sprinting mechanic that works with the existing click-and-move mechanic, where whenever a key is pressed the current movement speed (max walk speed) of the actor would go up significantly, and resume to normal when released. I've tried several ways based on existing answers and it did not show any result in game. What would be a good way of approaching this?

Second: The click-and-move pathing is a little bit too smart for what I want, which is a more direct move-towards-the-mouse functionality without intelligently pathing around obstacles (would really make a maze pointless, that one). How should I go about doing that?

Thanks!

Product Version: Not Selected
Tags:
more ▼

asked May 18 '15 at 06:09 AM in Blueprint Scripting

avatar image

LeoJr
3 1 2 3

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

1 answer: sort voted first

To your first question: Go into your character and implement a "Event " (ideally you make this a "Event Sprint" by adding it to the inputs in your project settings so it's not locked to a key and you can rebind it later but for testing this works just as well). From that event "On Press" get the character movement component and change the "Max Walk Speed" to the high number and the other way around for "On Released".

To your second question: In this case you actually want to get rid of the "Simple Move To" node in your script right now and replace it with a "Add Movement Input". This requires a vector for the direction in which you want to move. To get this vector do a "Get Hit Result Under Cursor" which will provide you with a hit result. Once you break that you will find a "Hit Location". The vector between your actor and that point is the vector you want to input (Hit Result - Actor location).

I hope this helps.

Cheers!

more ▼

answered May 18 '15 at 03:21 PM

avatar image

Erasio
6k 291 86 293

avatar image LeoJr May 18 '15 at 04:30 PM

Thank you so much for your response! I've implemented your answer to my second question and it works perfectly now.

The first problem persists, though. You answer is pretty similar to the other stuff I've tried before - it compiles ok, but the key press/action event does not change the movement speed of the character during runtime (manually changing it before runtime does work, but that's just the consistent max walk speed which is not what I need). Also note that most of the functions happen on the controller blueprint, not the character - don't know if it makes a difference. Any ideas?

current

u4-char-dash_01.jpg (320.4 kB)
avatar image Erasio May 18 '15 at 04:45 PM

Ah I think I know why. What is the speed you specify in your "Add Movement Input"? Because for the max walk speed to change anything your walk speed has to be above the max walk speed you are setting it to ;)

avatar image LeoJr May 18 '15 at 05:10 PM

I actually couldn't find the add movement input node, any idea where it could be? i looked under the character blueprint, which has pretty much nothing, and the controller blueprint only has the click-to-move functionality but no specifics about the movement itself.

avatar image Erasio May 18 '15 at 05:42 PM

What are you using to move your character?

avatar image LeoJr May 18 '15 at 05:49 PM

I'm... Not sure. the top-down template has the controller with the click-move functionality, and the character itself has nothing except the inherited character movement.

avatar image Erasio May 18 '15 at 05:58 PM

You modified it as I described in the initial answer didn't you?

avatar image LeoJr May 18 '15 at 06:06 PM

Yes, I did, sorry! where does the speed get specified on it?

alt text

avatar image Erasio May 18 '15 at 06:08 PM

It should be a combination of the length of the "World Direction" vector and the scale value. Maybe it automatically defaults the world direction to one. Try setting the scale to like 10 for testing.

avatar image LeoJr May 18 '15 at 07:33 PM

that's what it was, and it works now! thank you!

One thing I had an issue figuring out was that the scale could only accept values between -1 and 1. I had it set to 2 for a while and couldn't figure out why it wasn't working.

Again, thank you very much! :D

(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