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 make a raycast start position change

Hello! I was wondering about how do you make a raycast's start location change by a value. I have my raycast currently setup with the start position being the actors start position. Would I have to add on values to make the start location move? I am trying to make the raycast move a predefined amount to the left or right depending on which bullet the player is on (I have an ammo system already in place, and the branch is working, I am just wondering how to make it move to a predefined location each time the player fires). Cheers!

Product Version: UE 4.10
more ▼

asked Jan 07 '16 at 07:55 PM in Blueprint Scripting

avatar image

86 18 19 25

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Just add some value to the player position before feeding it to your start position.

If you want to move it relative to the player position you have to get "Forward Vector", "Up Vector" or "Right Vector" and multiply it by however far you want it to be deplaced.

Those three vectors are all exactly one unit long which means multiplying the vector with 100 gives you a vector with the length of 100.


more ▼

answered Jan 08 '16 at 03:59 AM

avatar image

5.9k 291 86 292

avatar image Designer102 Jan 09 '16 at 04:45 PM

Thank you, but my current system has no up vector or right vector, instead just the forward vector is the starting position, how would I make that move to the side or up and down? Just multiply it, or do I need to get the up vectors and forward vector for this to work?

avatar image Designer102 Jan 09 '16 at 04:56 PM

alt text

That is my current start position script, what would I multiply or add to make it change the start position?

screenshot (12).png (138.5 kB)
avatar image Erasio Jan 09 '16 at 05:01 PM

The start position of the trace?

Whatever you want. It's just a vector. You can do whatever you want with it.

I honestly don't know what exactly you are asking.

avatar image Designer102 Jan 10 '16 at 03:25 AM

How would I make the linetrace start position move up or to the side with this current BP.

avatar image Erasio Jan 10 '16 at 03:28 AM

Are you familiar with vector math? Even just the basics?

avatar image Designer102 Jan 10 '16 at 08:57 PM

Yes, what I meant was how could I make the linetrace move whenever a variable is at a certain number, not the vector BP's.

avatar image Erasio Jan 10 '16 at 09:04 PM

You can just add a certain number to your vector via a simple add node.

Just search for + in the context menu and it'll show up.

Or select whether or not it should be modified by adding a "Select" node right after, one getting the modified result, one getting the original one.

You can do pretty much everything you want with the vector itself. I'm just having trouble understanding what exactly you need. Move the line trace start position.

Easy. Vector -> + -> Enter the value you want to move it by in the fields for the second array. Done. You can do the same with multiplying either each value by another one or all with the same value (vector * float).

You have a base grid. Your world. Everything you place in the level, every blueprint you spawn will be placed relatively to your level. The vector resembles the path from the origin of the level to your actor since all vectors have a direction. You can then on top of that location add whatever you want by simply adding other vectors ontop of it, move it around by changing the values and so on.

Right now I really can't get a picture of what exactly your problem is.

avatar image Designer102 Jan 10 '16 at 10:20 PM

I have already tried adding my actor vector to another vector, and it did not work.

alt text

screenshot (13).png (115.6 kB)
avatar image Designer102 Jan 10 '16 at 10:32 PM

I got it to work! I added the actor vector with a float and used a branch to determine which value would be chosen. Thank you for the help!

(comments are locked)
10|2000 characters needed characters left

coordinates are your xy(z), if you change any of them you change your position, z being the altitude. So it all depends on where you want the vector position to end up. I would get a fresh vector of the end location and interpolate to that, unless you're doing something like a non-linear trajectory trace, in which case you would want to offset your starting position by a small amount each step, is that what you are trying to do? here is a small example I use for tracing my jump trajectory, unfortunately you have to take all your variable changes into account, so if you mess with speed (of the bullet?) later on, or with friction, it won't be precise.alt text

more ▼

answered Jan 09 '16 at 06:39 PM

avatar image

66 1 6 9

(comments are locked)
10|2000 characters needed characters left
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