Grenade Bounce Quake Template!

So the problem is fairly straight forward I would think. The image explains and shows everything. I am seriously willing to bet this is a simple problem to fix. But for now I just dont know how to move forward. Anyone have advice?


This is the same example i gave you some time ago.

This formula gives you the new bounce direction vector. Any new traces after the bounce need to account for this change in direction. So assuming your TraceBegin is always at the location of the object in the current frame, your TraceEnd should now be the new bounce direction vector multiplied by whatever distance your traces are.

Replied to your Tweet but here as well:

Use a “Mirror Vector by Normal” node. The vector is the velocity (or direction) of your grenade. The normal is the wall normal (you’re on “impact normal” in the screenshot).

Then I guess you’d want to set the velocity to the new vector. Also, if it was me, I’d be saving the current velocity to a variable and adding that on to the location right at the end, rather than trying to plug in reflection stuff directly into the “set location”.

  • If you’re trying for Quake style, I think they’ll reduce the XY velocity on the bounce - but don’t quote me on that.

**Edit: **As far as I can tell you’ve got the maths right, but you should be plugged in to “Normal” not “Impact normal”.

Didnt even know that existed. Haha.

I have tried different variations of this and the result I get is usually really strange. The grenade mostly just warps all over the place exploding in random places. If you check out the image you can see I have something along the lines of what you suggested. No matter what I plug into anything. It goes all over the place. Hmm

I have tried a few different things so far. I have to say that out of all of the current things I have been working on this one is the hardest for me to grasp. I just cant wrap my head around how to do this.

Ill donate $10.00 USD worth of bitcoin to anyone who can show me a working example of this problem. $15.00 USD worth of Bitcoin if the solution can be plugged into the current nodes I have right now. By working example all I mean is a image that shows the nodes and how they need to be hooked up to the current setup. no need for a demo or anything. The goal is a grenade that pretty much just behaves like Quake 1-3 grenades.

Even if it requires a lot of reworking it will be worth it.

I’ll take you up on that. I’m assuming you’re wanting it to stay with the locations being set, rather than using velocity?

This should be it. You can copy / paste it directly into a blueprint from this site. All I did prior to this was create an actor and create the “MyVelocity” vector variable, just as a way of storing how far it should be moved each tick.

Also I multiply the velocity by the delta time, so that it’s framerate independent, but that part could be skipped (shouldn’t be though).

Ah awesome think you so much!

Ah awesome, ill probably have some questions. The biggest issue I have with this is that the math is over my head and thus I just become useless in understanding the solution. I’ll study your solution.

One of the reasons I am using the set position is that I want the projectile to be able to change direction and simply loop itself forward even if it twists turns or arcs. I plan to replace the set position with a move to position to create interpolation. Once I get that in place the velocity will just be how quickly it travels across the trace.

Ill go over this today and hopefully with about 8 gallons of coffee I can comprehend it on about 3 hours of sleep ><

PM me your QR code for the bits!

edit: Question, I notice that you set the velocity to (200, 0, 0) Is the first number of a vector always forward???

I have run into a new problem. I can get the grenade to bounce but it will often get stuck on the surface it last hit…

If your doing what i think your doing, you need to account for the Radius of the Grenade. When you start your new trace from the Hit Location it may be slightly inside the Geometry, try moving the grenade off of the Hit Surface by its Radius amount.

Actually I have it all working right now. Bouncing is fully functional at this point in time. Its going to require some reworking to get all of the old variables to function correctly again but as far as I can tell right now I should be able to get this all setup pretty quickly.

My only question now is if this method is going to cause way too many traces? Every projectile seems to do a tiny trace every frame. Not sure if that is a good idea!

Traces are relatively cheap these days.

You can perform hundreds in a frame and see minimal impact.

I suggest doing some stress tests to see how it performs.

What about in the case of a multiplayer FPS? wont each trace need to be replicated?

Line traces are performed by the client unless its Authority run, then its on the server. The movement of your Grenade would be replicated.

I guess this leaves only one question left.

I am having trouble getting the above blueprint to add falloff on the projectiles. For example having a simple variable I can set that determines how much a projectile is effected by gravity. I try to modify velocity but that doesnt seem to work. neither does modify the rotation of the object. I wonder how I can add a falloff on this. hmm.

Each tick you can add something to the Z velocity. That’s why it will help to have a velocity variable to keep track of the current speed. Then your trace will always be FROM: actor location, TO: actor location + (velocity * deltatime)

To get the gravity acceleration to be framerate independent, you’ll need to figure out the formula for acceleration. I’m not too good with the maths side of things but IIRC it’s 0.5 * gravity * (time * time).

So, Velocity.Z += 0.5 * 9.8 * deltaTime^2.

Also the Quake 1 & 3 source is available if you need to look up how they do the maths for things like this.

Well currently right now I am using your exact script. so the projectiles move independent of frame rate ect. Its really nice actually!

As far as the math, oh man vector math is just a bit out of my league. So I am trying to imagine what the nodes for Velocity.Z += 0.5 * 9.8 * deltaTime^2 will look like.

I also am kind of thinking about adding falloff to every weapon except the thunderbolt and the rocket launcher. Just to varying degrees.

Also Uunx I haven’t not paid you yet for your help.


You can use Math Expression nodes to simplify your logic.

The above demonstrates “Velocity.Z += 0.5 * 9.8 * deltaTime^2”

That link will give you more information on Math Expressions.

Oh that’s amazing I had no idea I can input math expressions like that! Ah hell man I could have done a lot of stuff with much fewer nodes if I knew about that!

I played around a little bit and got an effect that arcs to the left in some strange angle. LOL

I imagine that the course change needs to happen after the first trace though. So I set the new velocity after you pull the trigger and the projectile leaves the barrel so to speak. Whats strange is that anything I do seems to either not have an effect or it just goes way off in a crazy direction :smiley:

Math Expression nodes have their limitations though, they are faster however than having the nodes laid out expressly.