Hey everyone, I’m working on deterministic bounce physics for a project. I’m using line traces to get a list of vectors I want the projectile to bounce between.
This is the function that is called to set the velocity:
It’s called on beginplay and when the projectile hits something.
[NEW USER: LINKED IN COMMENTS]
THE ISSUE: When the projectile hits something for the first time, the velocity can no longer be set. The velocity can still be set if it hasn’t hit anything yet. I attempted to resolve this using this method:
[NEW USER: LINKED IN COMMENTS]
Unfortunately, this method does not seem to change anything.
I can confirm after a lot of troubleshooting and debugging that all the bounce points are correct and there isn’t an issue with the vector calculations.
How can I ensure that the projectile movement component will still be functional after the projectile has hit a wall or enemy?
There are a few reasons why I would prefer to use the projectile movement component/velocity in this instance over interpolation.
The first, and most important, is that while I want the physics to be somewhat deterministic, there are still some random elements in the game. Potential bounce points can move, causing the object to miss them. In this instance, I would not want the object to act as if it bounced. There is currently another behavior that I have triggered when that happens, but it shouldn’t be relevant to this blueprint.
There are a few other reasons, like the rotating of the object facing the current direction and other QoL options that the Projectile Movement component provides.
Can’t see it mentioned in the thread. Is Shield simulating physics or solely relying on the PMC? There are cases where you cannot (and should not) have both.
When the projectile hits something for the first time
How many times does it actually Hit - as hits can be temperamental and can trigger more often than one expects. Are you counting them or eyeballing it?
there isn’t an issue with the vector calculations
Irrelevant here but you can replace the - and Normalise nodes with Get Unit Direction.
understood, how does your game work? if its not completely deterministic then the BouncePointVectors could be wrong by the time the projectile reaches the location?
if it is accurate then don’t use EventHit as Everynone mentions the hit may not be the correct bounce point or you could get multiple hits skipping a point
Haven’t noticed Hit being temperamental in this instance. I am counting them, but there is a fallback for if the hit happens where it isn’t supposed to.