It’s not possible to make a projectile end up at a specific point, unless you write your own projectile.
But it is possible to know where a projectile will end up:
I have no idea how this guy does it…
It’s not possible to make a projectile end up at a specific point, unless you write your own projectile.
But it is possible to know where a projectile will end up:
I have no idea how this guy does it…
How can I let the projectile move to a specific end point. I have made a line trace that starts from my weapon’s muzzle, towards somewhere around the center of the screen (line trace end location will be randomly generated). So I don’t know how I can specify the projectile’s end point.
The above is projectile prediction, it’s in the engine and it’s pretty straightforward to set up:
I’ll admit I’m not sure I understand OP’s question. Since we’re tracing, you have have all the data already beforehand. Wouldn’t it be a matter of moving the projectile with a timeline / tick? This would render the projectile component redundant, though.
Ok, did not know that stuff was there
Yes, obviously if you already have the destination you can plonk a tennis ball there, but I think the OP magically wanted to force an engine projectile to finish there.
Ok, I think we were assuming you meant a projectile that arcs
I was assuming something funky Mildly disappointed. Booo
I start my line trace using whatever input I want to fire the projectile at the camera (using the camera trace), and get its world location and world rotation. The world location is the “start” of the line trace. I then get the forward vector of the camera’s rotation and multiply it by a float variable called “trace distance”. I then add that to the camera’s world location. This is the “end” of my line trace. When it hits something, I break the out hit, and promote the “impact point” to a variable (called by the same name). Also, to make my life easier, I always place a crosshair at the exact center of the screen before I start. When I finally get to spawning the projectile, I use a “find look at rotation” node. The start is just the world location of the camera (which I usually just get again, instead of making it a variable), and the target is the “impact point” variable. Remember, the impact point is set before the projectile even spawns, as the line trace is basically instantaneous and the variable is set a certain number of ticks before. So the return from the find look at rotation populates the rotation pin on my spawn actor from class (which spawns the projectile). I use the forward vector of the socket location or scene component where I want the projectile to shoot out from. The spawner’s transform requires at least a location vector and a rotation vector. The location (for me) is again the world location of the camera, and the rotation pin is fed by the output of the find look at rotation. I usually turn on the debug trace and set it to “for duration”, so I can visually confirm that my projectiles perfectly intersect with both the crosshair and the little hit markers that appear at the end of the trace when it hits something. Of course, you have to know about collision responses and traces to make this work. This is just a basic description, with the assumption that no gravity is applied to your projectiles. For energy weapons and magic projectiles, this works well for me.
I hope I didn’t accidentally make a mistake in describing this. It’s easier when I’m in front of my computer and looking at it. It also helps to not be around 90 seconds from sleeping when posting advice like this!