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"

How to create Grenade arc using Blueprint?

Hello, I'm trying to create some sort of a Grenade launcher, but I need some sort of an indicator to showcase where the grenade will land when I fire it. Something like this (Screenshot is from the game The Evil Within)

alt text

I'm a beginner at both Scripting and Blueprint/UE4 so please keep that in mind! Thanks in advance.

Product Version: Not Selected
Tags:
more ▼

asked Nov 30 '14 at 12:12 PM in Blueprint Scripting

avatar image

Castellanos
8 3 4 7

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

2 answers: sort voted first

if you want a solution that will work with arbitrary gravity and bounce prediction, you are going to need to copy all the code that alters the projectiles trajectory initially, during tick, and during a bounce, and put it in a for loop that is called by tick if the player is aiming a grenade. the loop will trace lines between points to create the arc.

inside the forLoop, any code that usually needs DeltaSeconds, should instead be given a float variable you can call DeltaSim, which is just the amount of time that passes between each point in the grenade arc. by adjusting the number of iterations of the loop, you can adjust how long the line is.

but inside the simulation for loop, instead of spawning anything, you are just copying the position to an array, then updating the simulation variables to solve for the next position. and if you hit something, you change the velocity using the same formula the projectile uses to bounce.

more ▼

answered Dec 01 '14 at 01:37 AM

avatar image

ScottSpadea
9.2k 315 193 431

avatar image Castellanos Dec 01 '14 at 04:33 PM

I must say, you lost me a bit there, sorry! Can you explain it in a step-by-step fashion with pictures? Like I said above, I'm a beginner, some of what you've said sounded alien to me.

Sorry if that is troubling you, but I'd appreciate it!

avatar image ScottSpadea Dec 02 '14 at 04:57 AM

in order to predict where your projectile will land, you need to have access to the projectile physics/movement code, so you can do it by writing a custom projectileMovementComponent in C++, or you can do all of your projectile math in blueprint.

alt text this should be enough to get started, but this solution doesn't calculate bouncing off of surfaces, and it doesn't work with the physics of projectileMovementComponents. Since i will use a similar system in a game i am making, at some point i will finish this mechanic, and possibly sell it as part of a marketplace weapon mechanics pack, but for now i have some other things i need to work on.

so if anybody at Epic likes the answers i give, and wants to hire me to write more complete tutorials with step by step instructions, maybe as a trade for a free subscription to ue4, or as a part time job as a forum moderator, i can go into further detail with these complicated answers. but so far i just answer these questions in my free time for problem solving practice, so i may not always have time to make visual references or full tutorials.

avatar image Castellanos Dec 02 '14 at 05:37 PM

You're such a saint, my friend. Thank you!!

avatar image MohdNadjib760 Dec 28 '14 at 07:48 PM

Hi there. Is there a way to do this using beam emitter instead of debug lines?

avatar image ScottSpadea Jan 03 '15 at 02:25 PM

probably. beam emitter is not really designed for interpolating between points you create, so you might want to write your own version of beam emitter, but if you want to use the standard beam emitter, you would need to have target actors that you move into the first and last point position, and calculate the tangents by subtracting the first point from the second point to get the first tangent, and subtract the last point from the penultimate point, for the second tangent. if you calculate bank shots, you will need several separate beam emitters spawned at every collision, and since that would be expensive to spawn those in all the time, you should have a small pool of beam emitters that you move into place and keep alive for as long as the weapon is equipped.

avatar image UnlikelyHeroesStudios Jan 03 '15 at 06:18 AM

So DeltaSim is just a float variable that increases by 1 - connected to the Event tick somewhere?

What about the values for Air Friction, Gravity, Gravity Scale? Are you setting those from values generated elsewhere, or are you just setting them and playing with them with arbitrary numbers (until you get the desired effect)?

Sorry if these are stupid questions. Really looking forward to trying this out (I'm about halfway through now.) TY again for posting this. :)

avatar image ScottSpadea Jan 03 '15 at 02:02 PM

DeltaSim is just set to a default of 1 and stays that way. if you adjust this number, it adjusts how far apart the simulation points are.

air friction is unused, and not important unless your projectile is a leaf or a parachute.

gravity and gravityScale are globally tuned by a designer base on how the game feels, and grenadeLaunchVelocity is tuned based on how the projectile trajectory feels.

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

Use the predict project path :D this work great for me alt text

screenshot-106.png (169.9 kB)
more ▼

answered Oct 09 '17 at 12:47 AM

avatar image

pepebando
1 1

(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