I have a projectile and tried to do some damage to enemies but when i want to delete projectile when it hits to enemy, it deletes almost immediatly, i think it is because of line trace hit works before projectile actually hits, how can i fix this problem, thank you for your helps
I addition to this i have also another problem, which line trace by channel shows that i hit something but actually there is nothing to hit like in the picture
A projectile doesn’t fly along a linetrace anyway.
Use one or the other.
The line trace will always work.
The projectile is highly inaccurate since it depends on unreal’s physics working.
You can predictprojectilepath or figure out mathematically if a hit will be true or false at the time of the throw - assuming persistent physics/motion ofc.
Also, what you do and how depends on usage.
Multiplayer online game? Definitely server driven linetrace over physics.
(Not that you can’t, but people will be able to cheat the system without even trying due to frame speed/physics calculation disparity. Plus youd need to manually set up some sort of replication check and balance for it that the line trace wouldnt have to contend with).
Single player vs pc?
Physics will work and be as accurate as the GFX allows it to calculate/run.
ProjectileMovementComponent updates the position of another component during its tick.
Behavior such as bouncing after impacts and homing toward a target are supported.
Normally the root component of the owning actor is moved, however another component may be selected.
If the updated component is simulating physics, only the initial launch parameters (when initial velocity is non-zero) will affect the projectile, and the physics sim will take over from there.
What type of shooting mechanics are you going for? Simple Arena or Realism?
Is the projectile component more for visuals?
Do the projectiles have any arch?
Multiplayer or Single Player?
ComputeMoveDelta is based on the Verlet Velocity Integration
Not sure what you’re getting at here. PMC forces sub stepping and CCD. Even if I use a ridiculous velocity of 600,000cm/s on 60Hz tick (16.667 tick step), ala 100m a tick. I get hit results at any distance. PMC SWEEPS. spawn location → tick distance etc will get hits.
I can fully demo this with a 2cm radius or smaller projectile all day.
From how I had things set up in the past on a cannon ball like system:
PMC defaults back to physics after the inital launch.
With substep on, and realistic ballistic speeds (for a cannon so not even that fast) - the sweep missed hits on smaller objects (players) all the time.
Just because the object (using physx at the time btw, so not even with the mess which is Chaos) was traveling at speeds which made it impossible for the collision to catch the small item between steps.
Ofc if you up the sub step enough you eventually do get results - but this costs you a lot in performance, to the point it is not viable for your ran of the mill system sporting (still) a 1060, and the computing CPU equivalent of a microwave oven…
Maybe UMovementComponent would produce different/better results.
I mean, its as easy as extending the collision area of the projectile in the direction of travel by the 1/2 speed of travel in a tick to get plausible hit results anyway (which is what ended up happening to utilize physics anyway).
Its not impossible to force any system to provide results.
The real question has to be (like I mentioned) application.
Having a server simulate and provide results will have people cussing due to “lag” -Its not lag at all, but wtf does the avarage player know anyaway?
While in single player you probably wouldn’t even notice or have issues…
Btw, I for one would be curious to see a practical demo of this using Chaos/latest actually working engine.
Havent really kept up with tearing the engine apart to make it work since I moved the last project to CryEngine for better rendering…
Like I was saying PMC doesn’t use physics at all. It’s literally interp step on tick with a collision sweep.
Anyway I roll you a demo tomorrow getting accurate hits on client and server.
2cm projectile collision component at 600,000cm/s or whatever speed connecting with sheets (planes) at whatever distance.
All without modifying sub stepping… default settings.
For clarity…
Velocity: 600,000cm/s (6,000 m/s), this gives a tick step of 100m when ticking at 60Hz.
e.g. every 16.667ms we move 100m, at least initially. Gravity being applied.
M24 Sniper rifle has a muzzle velocity of 869 m/s.
Here are my PMC settings. I’ll show them in the vid as well.
I’m running a client-fakey, server auth setup. Client fires a local only projectile for simulation, fx and responsiveness. RPC’s the server to fire.
Server calc its own firing trajectory and fires a server only (no rep) projectile. Then multicasts a sim proxy only fire event.
Server handles damage, death etc. Replicates out hit results for decals/fx on other clients machines.
Here you go.
velocity: 600,000 cm/s
Target is a sheet plane (100x100x0) with a box primitive collision (100x100x0).
Projectile collision is 0.1cm radius (2mm diameter)
The issue was really never for when stuff uses the PMC though, rather for when you do simulate the physics…
But, personally I’m still amazed that it works fine.
Im about 60% sure the older version (4.22 I’m guessing) wasn’t capable of always returning hits on a single sheet. Not even with the PMC.
So, at those speeds you’d resort to calculating the ark trajectory and getting the hit value of whatever object(s) transected it.
Little trial and error and some basic knowledge of ballistics, and you can also pull the exact time the hit would occur.
So you can hit moving targets at 2mi which just happen to run into your predicted path, for instance.
From what you described above, I’m guessing they implemented just this as part of the PMC now.