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"

Need to shoot projectile at an angle with variable power

I am wondering if it is possible to shoot a sphere projectile actor from a spawning actor in a specific angle (maybe the X axis rotation of spawning actor). I am trying to launch a ball up a track. I will acquire power amount from how long the fire button is held. Upon release of fire key I can spawn the ball and add an impulse though I am only adjusting Y and Z of vector input in Add Impulse node. Is there perhaps some other way to go about this.

In the current case I am only adding some Z value for upwards lift. Could I just calculate it roughly? The Z value would most likely always be lower even if the shot is launched at max power. I need it to launch into the angle of the track not bounce onto it.

Here is a small figure example of the behavior I'm seeking. Blue arrow is Z axis of cube, Green is Y axis.

alt text

Product Version: UE 4.14
figure01.png (48.5 kB)
more ▼

asked Apr 30 '18 at 04:05 PM in Blueprint Scripting

avatar image

15 2 8

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

1 answer: sort voted first

Possible nodes you can use to get direction vectors:

Actor -> Get Actor Forward, Get Actor Right, Get Actor Up

Rotator -> Get Forward, Get Right, Get Up

(My Target location - My location)-> Normalize (if you wanted to aim at something).

If you want to get the local +Y of your "spawn actor" then it would be Get Actor Right. Remember you can also get the rotation of a bone or socket then get it's forward, right, etc too.

Just multiply that value times "shoot power" or whatever and use that as the impulse you add. You will effectivley shoot in that direction.

alt text

Oh yeah and in UE4 local Forward = +X, Right = +Y , Up +Z.

more ▼

answered May 01 '18 at 01:22 PM

avatar image

112 3 8 7

avatar image Atekom May 02 '18 at 02:17 PM

Thank you! Used a dummy cube to derive a base target vector that I can fine tune later, perfect! The target location minus spawn actors location to normalize was what I was looking for. Here is the snippet of nodes. Again thank you for your assistance!

alt text

ballshootercube.png (254.4 kB)
(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