There are probably at least 3-4 ways you could do what you need. Just thinking off the top of my head here…
Make your current ball invisible and increase the speed to the point it would seem instant to travel it’s maximum distance. Then each time it collides store the vector of the collision point. Then when it has reached it’s limit, spawn a spline using the vectors of each collision.
Making fast moving objects in unreal has one big problem. When you get to 2000-3000 speeds they sometimes go trough walls. I tried this fast moving projectile thing for weapons, and it does not work well.
Instead i used line trace. You can trace line in direction you are aiming. You get location and normal vector in hit spot.
So you have direction of incoming lazer, normal at hit point, you need to calculate bouncing vector.
Easiest way is to normalize incoming vector, negate it then rotate 180deg around normal vector. There are probably faster methods (you should google this), but that rotating is first that came to my mind.
Co now you should have impact point and calculated outgoing vector. Shoot new lazor.
This also works great with beam particles, you can spawn new beam particle for each line trace.
I see 2 line traces in your BP but there are actually 3 line traces shown in your image so it is a bit hard to narrow down without more information.
In your image of the game, there is a line trace that appears to be going from the character to the correct mouse location. What part of your script is generating that trace? You need to isolate to that part and make sure that part is being used for the reflection.
I use only line trace to show where I am aiming (dunno how to make a drawn dotted line from player to mouse cursor).
The other lines are where I attack.
When the player attacks the laser should continue until it hits something and then bounce until it has reached max # bounces.
That’s why I need to the laser to continue past the mouse cursor, otherwise it stops at it.
Like shooting a projectile that bounces endlessly until it hits something and bounces until it has reached max # bounces.
Looks like your 1st line trace is trying to ‘project’ the line by multiplying by 5000, but that is an actual world space location you are tracing to. You do not need to multiply that by 5000 there.
Also you may need to convert the position into a vector before doing “Mirror vector by normal”. That vector can just be Normalize(Start - End). Then you mirror that, and then multiply the result of the mirrored vector by 5000 (or whatever your max length it)
I don’t understand well what are you trying to achieve , here is my comprehension :
You want to fire a laser in a direction and it will bounce from wall to wall ?
It will bounce continuously until it hits a player or the laser has a certain lifetime?
The first attack linetrace expects a start and an end:
Start - where the player is
End - where the mouse cursor is
But if I’m not aiming at a wall (as you can see in the example images in my previous post) the linetrace just stops, i.e: nothing happens, it doesn’t bounce anywhere.
That’s why I thought I’d increase the End point by multiplying by 5000 would help the linetrace hit something on the way to the end point.
I don’t quite follow what you mean, all positions are already vectors?
Players can shoot a laser.
The laser bounces on the walls, and hurts players if they are hit by the laser.
It doesn’t matter for how long the laser bounces or not, it’s just an idea of mine to have a powerup that allows the player to have their laser bounce more times before being destroyed (because it didn’t hit any players)…
If there is no hit, you need to handle that case by using the “Return Value” of the line trace. If there is no hit, then you need to set the hit point manually to be the end point. Use a “branch” node connected to the return value for that.
In terms of “vector vs direction”, what I meant is that you cannot multiply a position by 5000 in order to ‘cast’ it out. That will simply scale the position from the origin (0,0,0). To scale a position relative to another position, you need to first subtract the position you wish to scale from. Then you could multiply it by some number and then re-add it to the start position. I usually normalize to have exact control of the casting distance, since if you don’t, the scaling will be relative to how long the initial trace vector was which could cause issues in some cases. But yes, technically all positions are vectors, they just aren’t relative to your ray so they weren’t really being used as directional vectors as it appeared they were meant to be.
As I said before, you need to trace to the mouse cursor as the end point and handle the ‘no hit’ case. If you need the end point to fire offscreen, then you need to convert your position into a normalized direction vector and then you can multiply it by a large number and add it to the starting position to cast it out further. That was the Normalize(start - end) bit from my last post. Hopefully I made things less confusing not more confusing this time.