Here is my task. An archer-player holds the Fire button for some time to increase the shot power. Archer and bow play for some shot animations. On button release the arrow flies with initial speed based on power calculated. All the clients should see the arrow flight and the shooter animations. Dedicated server.
I’d like to use the property of Projectile Component for natural flight.
With the fire button press I start an event on server that plays the anim and counts the initial speed for future arrow.
In the Construction script of the arrow I get the arrow’s owner(the archer), get the variable calculated before, and set the Initial Speed property of the arrow’s Projectile component.
The flight trajectory is perfect, but all clients, even the arrow’s owner, see the arrow, with the sharp point down. It flies all the way “looking” on the ground, like it is shown on my picture.
Besides the fact that I’m not an artist, it’s obviosly seen that on client side “Archer’s” variable InitBulletSpeed is 0. Debug shows that the problem is that all the clients, even the arrow’s owner “do not know” who is the owner. So, when the arrow’s Const Script runs on a client, function GetOwner returns None.
It should be said that of cause both the archer class and the arrow class have properties “Replicates” and “Replicate Movement” checked. Projectile movement component of arrow also replicates. Relevancy props are in default states.
So, I can’t understand why the owner is not known by clients, I can’t transmit any data to Const Script(for example, the archer-shooter, or speed var from him), and I can’t set the arrow’s init speed anywhere except the Const Script.
I would be thankful for any ideas!
P.S.
I’m not sure, but may be it’s important - archer class is not the default player’s pawn, it is created during the game.
You state that the flight path is fine but it just faces the wrong way…
I assume that your arrow has a Blueprint? Go into the Arrows Blueprint and in Viewport try rotating the arrow in the Transform setup
Velocity is not replicated from sv to client, so i think u cant use Replicated Actor to perform this Rotate follow velocity. Instead of that, u can use the Combine func Run on Server + Multicast to spawn the Arrow on All Server and clients, and make sure the arrow does not replicated. And when the Arrow collide with something, u can check if that arrow is on server → do your logic here. That is my solution for this.
Thanks for reply, but your variant is not right. There is a feature in of Projectile Component named “Rotation Follows Velocity”. It rotates object dynamicaly.
Hiengs2702, I think you may be quite right. I had no time for my project, but as I remember, my solution was to treat the arrow like an FX-effect, when there is no arrow on server but every client creates it’s copy of arrow. As I remember, quick test showed that there was no problems with applying damage. I mean damage multiplication. But I’ll try you solution when I would have time. Thank you!
I know that it rotates dynamicaly. But it also assumes that your projectile is facing the way you want it to go before you start.
I am using this to launch a missile. It works on both server and client.
When I started the missile also went like your diagram. I rotated it as I mentioned in my earlier post and it works fine.
I did not think it would be worth writing but then I saw the topic was alive Dec 20.
I’ve had the same issue, which brought me here. I took Hien’s advise and mixed it up a bit.
The projectile movement component is set to rotation follows velocity.
however, the actor, the niagara effect, the projectile movement, is all not set to replicate.
When I fire the function, i use multicast. This gave me a clean effect. I suppose, running your collision on server would be enough. No need to multicast
For anyone having this trouble, I got it. All you have to do is to replicate the Arrow, replicate the Arrow’s movement and set “Rotation Follows Velocity” ONLY FOR SERVER. This way, server will replicate rotation and movement of the arrow. If you set “Rotation Follows Velocty” on client, then he will put the arrow down because arrow’s velocity seems to be always 0 for client, when replicating (i think).