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)

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

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.

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!

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.

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.

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

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

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. :slight_smile:

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.

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.

Use the predict project path :smiley: this work great for me

1 Like

This is awesome! Thank you!

can u tell whats the value of all these variables?