My blueprint for homing projectile looks like this,
Executes On Server Custom Event → SpawnActor MyHomingBomb → Set HomingTargetComponent to target character’s (another player) Capsule Component
And my questions are
At server game instance the homing bomb moves towards the target character but it does not hit the character, it’s hitting very near the character but not exactly touching it. MyHomingBomb’s on hit event was triggered but the hit actor is not the target character! What caused this?
Is a character’s Capsule Component the correct component to be use for HomingTargetComponent?
At client game instance the homing bomb does not moves towards the target at all. MyHomingBomb’s replication is already set to true in fact MyHomingBomb was duplicated from my another projectile bp MyBomb (no homing) which was working nicely in both server and client game instance. Again what caused this? Looks like MyHomingBomb’s movement is not replicated correctly…
1 and 2 are actually the same answer funnily enough.
The capsule component is NOT your character. It’s what’s used for movement collision. You can turn it visible during the game (in your character blueprint, select the capsule component in the viewport and under rendering untick “hide during play”.
You can see it’s around your character but it’s a bit beyond it.
3 is a bit different. I’m not too familiar with the homing component and couldn’t tell if it has something to do with that component itself. But is your “Replicate Movement” box ticked?
I have found the solution for no. 1 by setting Homing Acceleration Magnitude to 10x of Initial Speed. The projectile can hit right at the character now.
As for no.2 so what’s the best component parameter to pass as HomingTargetComponent since the character capsule is not the most accurate?
Yes Replicate Movement is enabled. Anyway, I have found the reason for no.3 it is due to the homing projectile were spawned in server event and when replicated to the client the HomingTargetComponent which used the target character capsule’s object reference is not valid in client’s game instance as the memory pointer of the capsule is difference. The client has access to target’s PlayerState but the question now is how could I get PlayerCharacter from PlayerState?