Hey everyone I would like to have your thoughts on my replication system of bullets
what I have done is:
(treat the bullets as only visuals)
1-replicate the spawn actor node (So the bullets are Spawned By the server)
2-put a life span for the bullet actor
3-put event hit to destroy actor on hit immediately
(the downside of this is that when the client moves while shooting the position of the bullets isn’t accurate )
then I created a line trace to deal with the actual damage but I don’t know how to limit the line length so it won’t hit from far distances and also the line is very thin so you have to be so accurate while shooting or you won’t hit your target
so if you have a better solution please share it with me.
Hey there @Remous1! For the most part your solution seems fine. You can limit line traces range when you instantiate them. Your end vector actually determines how far it goes altogether.
If you wanted wider shots you could actually do sphere casts, which are just long capsules. This isn’t widely used however for a myriad of reasons, so I don’t recommend it unless you’re making a wide beam weapon, water gun, flamethrower, or something like that.
That said I highly recommend actually looking to the Lyra project as it’s a good look at best practices for replicated shooter elements. I played with it to learn more about the GAS (gameplay ability system), best practices for round based games, and of course the replication.
If you’d prefer to watch something instead of pick through Lyra, lastly an external resource, this user is applying replication to the TrueFPS community plugin. You don’t have to have the plugin to follow along with the tutorial and gather how it’s done. If you’d prefer to watch something instead of pick through Lyra. He doesn’t get to the shooting bit til roughly 5 minutes in.
Disclaimer: Epic Games is not liable for anything that occurs outside of this Unreal Engine domain. Please exercise your best judgement when accessing links in the forums!
Thanks for your reply it’s been really helpful but i have another question.
I’m using a set timer by event node with 0.1 timer to give an automatic shooting experience.
Is it better or shall i use a self loop technique with a boolean variable as a break? That part wasn’t shown in the video right?
And sadly I’m on a limited quota internet so downloading the lyra sample can be costly for me so do you really think it’s worth it?
Oh sorry! Forgot about the net limiter. Lyra is great but it’s pretty massive and it’s dense so unless you really do want to sit down and pick apart the “Best practices” it might not be worth destroying your internet for a month.
In my opinion, you have to be careful with delay if things can change. For example, if the delay is just “Can shoot again in 0.1 second” it’s fine but what if you change gun in that time frame? If your gun is still an actor and doesn’t go to data it should be fine, if not you have to handle edge cases in which if anything the delay iterates on is changed, does it cause any issues?
In practice it’s not bad, but I solve one or two issues a week here about the way delays work. If you are say iterating on a variable, but you have a 1 second delay, if your variable changes in that 1 second you won’t work on the old variable, you’ll work on the new one. Just something to keep in mind. Personally a delay for the bool seems fine depending on how it’s set up.
I do understand you yes and I didn’t face any issues so far testing it but which method is better for performance that’s what concerns me the most (since it’s gonna be happening rapidly).
to make sure we are on the same page here are the two methods I’m talking about:
The delay itself will be (ever so slightly) more efficient, but having the ability to stop the timer for longer timers would be useful. Barring any unforeseen consequences.