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"

Max speed to my character

Hi, I'm new in Unreal dev, and I'm trying to achieve a jetpack effect to port a cocos2d-x game of mine. I calculate the rotation angle of my character, and call Launch Character several times:

alt text

Problem is, it gets really fast, so I would like to limit the max velocity, but I can't find any option to do this. If you are familiar with cocos2d-x, I'm searching for a blueprint equivalent of:

character->getCPBody()->v_limit = 5000;

Oh, and I don't want to use ZOverride because I don't want to lose the gravity acceleration.

Thanks!

Product Version: UE 4.9
Tags:
more ▼

asked Oct 08 '15 at 07:34 PM in Blueprint Scripting

avatar image

puelocesar
16 2 3 5

avatar image puelocesar Oct 08 '15 at 08:41 PM

I made this workaround, but it doesn't work as well as v_limit on cocos2dx:

alt text

Any tips?

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

1 answer: sort voted first

Velocity is a vector. If you want to limit it to a max speed, do the following:

  1. Grab the current length of the velocity vector.

  2. Feed the current length of the velocity vector into a 'clamp float' node, where the min value is 0, max value is 5000 (or your max speed).

  3. Normalize your velocity vector.

  4. multiply your velocity vector by your clamped value.

more ▼

answered Oct 08 '15 at 08:47 PM

avatar image

Slayemin
829 50 29 73

avatar image Slayemin Oct 08 '15 at 08:57 PM

Alternatively, you can also just use the node "Clamp Vector Size" and apply it to your velocity vector. This does the same thing I described above.

avatar image puelocesar Oct 08 '15 at 09:09 PM

Clamp Vector Size was extremely helpful, thanks! Just one problem: speed isn't limited when applying force with "Launch Character". Here's how I'm doing: alt text

(where "Avoa" is a method that calculates the rotation and apply force using Launch Character)

This works well when I stop calling Avoa and character begins to fall.

(sorry for the non-english method names)

avatar image puelocesar Oct 08 '15 at 09:26 PM

ah, ok, inverting "Set Velocity" and "Avoa" did the trick! The order of execution in BP seems to be the inverse of what I thought!

(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