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"

Limit Vector Size in a radius

Hello,

I'm making an object which the player controls it by adding relative location.

What a want to do: When this object arrive some distance (length between Character and the object), they will not be possible to go any further, just to return, and keep in that radius without going away.

How can I do that?

Thanks!

http://i.imgur.com/QD8AOmX.png

Product Version: UE 4.15
Tags:
more ▼

asked Apr 21 '17 at 08:09 PM in Blueprint Scripting

avatar image

Bonatti-San
16 2 3 4

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

2 answers: sort voted first

Hi,

Just need clarification on something. Are you trying to keep the object within some distance of the character? Or are you trying to keep the character within some distance of the object?

If you want to keep something within a certain radius of something else, you can try doing this. Say we want to keep "B", within some distance "r", of "A".
1. Get the vector, let's call it "U", from the A to the location where you are trying to move B.
2. Get the size(length) of U and check to see if it's greater than r.
3. If it is greater than r, don't move B in that direction.
4. If B somehow ends up outside of the radius, just normalize U, then multiply it by r. Set this vector as B's relative location from A.

This is also assumes that B is also attached to A. That way B moves with A.

more ▼

answered Apr 21 '17 at 10:01 PM

avatar image

RoboScorpion
156 4 2 8

avatar image Bonatti-San Apr 21 '17 at 10:39 PM

Hi RoboScorpion, thanks for the repply.

Yes, the object is attached to the player, and will keep in the radius of the player.

I tried what you said, but when I set the relative location of the step 4, it reset the location to 0 when reach outside the radius.

Take a look if I'm doing something wrong: http://i.imgur.com/njeslIQ.png

avatar image RoboScorpion Apr 21 '17 at 10:57 PM

Can you try using a > node instead of a >= node?

avatar image Bonatti-San Apr 21 '17 at 11:21 PM

Yep. Same results.

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

Math your vector and clamp it after all. alt text

more ▼

answered Apr 22 '17 at 05:09 PM

avatar image

Two-faced
860 31 13 48

avatar image Bonatti-San Apr 22 '17 at 06:19 PM

Hello Two-faced, thanks for the repply.

I clamp the vector between A and B, but don't figure out how I use with the add relative location node

avatar image Two-faced Apr 22 '17 at 06:21 PM

Add location manually with + node)

avatar image Bonatti-San Apr 22 '17 at 06:28 PM

Sorry, I don't get it :( alt text

capturar.png (97.4 kB)
avatar image Two-faced Apr 22 '17 at 07:25 PM

You should get location, + it, clamp and set.

(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