#Tank game: Issue with Fastcast hit detection, and weld manipulation

1 messages · Page 1 of 1 (latest)

timid breach
#
scenic musk
#

from my experience with fastcast never try and simulate anything on the client all simulation should be done on the server

#

this is from the creator of fast cast

#

no need to read all this basically he says do it on the server

#

as for ur issue u'll have to do the rotation of the shooting point attachment on the server as well

#

or u could also ask the client where the bullets orgin should be shouldnt really affect anything

marble tulip
#

only do fastcast client side for stuff like client side particle effects

#

so there isnt a weird delay

#

but all damage calculations should be server

timid breach
timid breach
#

also so sorry for late response

scenic musk
#

u are also asking the client where they are firing from

#

say its a gun

#

the way fastcast works u have attachment in gun they have network ownership of

#

so u they can do whatever they want with anything they own

timid breach
#

well um idk if what i did rn was necessary but im making entirely separate folder and making cloned, fake tank and pivoting them where the OG tank is from the server

#

red is fake and normally colored is real

#

the red acts like hitbox

scenic musk
#

uh

timid breach
#

the red is slightly behind for the driver, the network owner which is normal right

scenic musk
#

yeah

#

well

#

it should also work

timid breach
#

the other players see the red tank forward to where the tank goes

#

is it also normal?

scenic musk
#

why dont u just use the tank on the server then?

timid breach
#

which one?

scenic musk
#

reds only a hitbox and tank on server is the visual representation of tank?

timid breach
#

red is what server sees the tank like tho right?

scenic musk
#

ohh i had it the other way around

#

its normal for the one on the server to lag behind a little

timid breach
#

the red one will not be visible to others

#

but like

#

if an enemy gunner aims at your tank

#

he sees it in entirely different position as you do

#

but none see it the way the server (red) does

scenic musk
#

well

#

im completely confused

#

however how i would do it is give ownership of tank to the one driving the tank

timid breach
#

me too

scenic musk
#

and ask the client to manipulate pointing direction and everything around those lines

#

only i would use the server to fire the bullet when the client asks

timid breach
#

do you wanna playtest my game so you can figure out more stuff? if you want

scenic musk
#

i would ask the server to tell me what ive hit

timid breach
#

u gotta join a group because its locked to testers

#

i will make you one

scenic musk
#

ok

#

Creator_Rat < my username

timid breach
timid breach
#

u good?

scenic musk
timid breach
#

you left

scenic musk
#

yeah well i didnt think i needed to stay

timid breach
#

come back you misunderstood what i meant

scenic musk
#

tell me here pls

timid breach
#

when you said player should tell where bullet should come from

#

you were right

#

but like

#

when the bullet begins to simulate on the server

#

there are other enemy tanks who have rotated their turrets

#

which change entire physical layout

#

the bullet does not know how the enemy tanks look like

#

they always think they are oriented at 0 angle

#

but that wouldnt be true

#

this is why i made the red hitbox thing

scenic musk
#

if the tank is owned by the character driving then the tank will rotate

#

if u go to studio

#

and rotate a part that u have ownership of it will rotate for everyone aswell

timid breach
#

the gunner does not have ownership of the tank

#

the driver does

#

and the gunner the one who rotates the turret

scenic musk
#

oh i see

timid breach
#

if i give ownership to gunner

#

rotation problem is sovled

#

but driver would lag

scenic musk
#

but the tank will lag behind

#

yeah

timid breach
#
while task.wait(0.033) do
    if script.Parent then
        if runService:IsRunning() then
            TurretRenderingEvent:FireServer(desiredTurretAngle, desiredGunAngle)
        end
    end
end
#

this is what the gunner client is doing

#
function RenderTurretForClients(plyr, gunRot, turrRot)
    local GunStats = TankStatsDictionary[plyr.Tank.Name].GunStats

    if GunStats.GunUpperAngle >= gunRot and GunStats.GunLowerAngle <= gunRot then
        local SeatPart = hum.SeatPart

        if SeatPart then
            if SeatPart.Name == "GunnerVehicleSeat" then
                for i, player in ipairs(Players:GetPlayers()) do
                    if player ~= plyr then
                        TurretRenderingEvent:FireClient(player, turrRot, gunRot, SeatPart)
                    end
                end    
            end
        end
    end
end
TurretRenderingEvent.OnServerEvent:Connect(RenderTurretForClients)
#

and how the server responds

#

^this is the important part

#

it sends remote to tell the other clients EXCEPT the gunner who rotated (because he already rotated it on his own client) to rotate the turret for themselves

#
-- Other clients
local function RenderTurret(gunRot: number, turrRot: number, seatPart: VehicleSeat)
   -- This does not run for the client rotating the turret
    if turrRot then
        seatPart.TurretRotation.C1 = CFrame.Angles(0, math.rad(turrRot), 0)
    end
    if gunRot then
        seatPart.Elevation.C1 = CFrame.Angles(math.rad(gunRot), 0, 0)
    end
end
TurretRenderingEvent.OnClientEvent:Connect(RenderTurret)
scenic musk
#

well

#

this is the obvious fix

timid breach
#

and the issue gets even worse if i want to have multiple turrets in 1 assembly (1 tank)

timid breach
scenic musk
#

well looks like someone in the devforums already has solved this

timid breach
#

i got the idea from this guy

scenic musk
#

im sure there is a simpler fix

scenic musk
#

well

timid breach
#

maybe i didnt read his code correctly im gonna do it again

scenic musk
#

if it works it works no need to think further

timid breach
scenic musk
#

probably the same way

#

if it works for 1 it works for all

timid breach
#

client

#

server

scenic musk
#

rotate it on the server too

#

although it will not in sync

timid breach
#

i mean it will

#

but its going to mess up the controls

#

also if u wanna know this guy uses welds

#

weld manipulation

#

and idk if the server replicates changes to Weld.C1 if the assembly network owner does it

scenic musk
timid breach
#

which will result in turret not moving almost at all

scenic musk
timid breach
#

jittering over and over

timid breach
scenic musk
#

yeah

#

well

#

another option would be to switch network ownership between turret and driver

#

when the turret user rotates the turret

#

but the problem with that is it will jitter mid way

timid breach
#

yep

#

im starting to lose hope now

#

ferrarico and mtc found a solution to this

scenic musk
#

what was their solution

timid breach
#

the only way is they used fastcast on the client

scenic musk
#

oh actually

timid breach
#

and SOMEHOW used the server to verify the hits

scenic musk
#

yeah u can do that

#

u can use it on the client and ask the server to verify the hits but

#

me personally im not a huge fan of that since the bullets will replicate at different rates

#

although for something like a tank missile or whatnot it shouldnt matter too much

timid breach
#

the only circumstance it would not matter if the weapon was hitscan

scenic musk
# scenic musk oh actually

i think one other solution would be to use a click shoot system where the turret rotates to where they click this way u can ask the client where they want to rotate

#

and ask the server to ask the client driving to rotate the turret

#

this way it will replicate for all

#

although idk what u have going on

timid breach
scenic musk
#

oh it does not?

timid breach
#

even if network owner

#

i thinkkkk

scenic musk
#

wait i dont think so

#

yk those

#

tool character

#

things

#

where theres tool on character

#

um

#

actually nvm that might be done on the client i think thats how i did it

timid breach
#

driver pov (network owner) sees it like this

scenic musk
#

ok

#

and server?

timid breach
scenic musk
#

change it on the server?

#

maybe?

timid breach
timid breach
scenic musk
#

change the c1 rotation on the server

#

i think it might instantly change back

#

but if u use renderstepped to change it and hold it there it could work

timid breach
#

wait

#

um

#

can you show me soem code that does this

#

because i tried something similar

#

and idk if i did correct

#

ly

scenic musk
#
lastRotation = 0

--We need to do this since the client owns the tank, it will only change for 1 frame and go back
RunService.RenderStepped:Connect(function()
  weld.C1.Orientation = lastRotation
end)

--this to change current orientation
changePivot.Onserverevent:connect(function(localNewrotation)
  lastRotation = localNewrotation
end)```
timid breach
#

i did something similar but it didnt work but i'll try again

scenic musk
#

see if it works

timid breach
#

if this works you're a lifesaver

scenic musk
#

well

#

i try to be

timid breach
#

im not doing it rn i've been coding the red thingy for 3 hours

#

gonna take a break

scenic musk
#

good thing to take breaks

#

i will say

timid breach
#

im gona tell you the results

scenic musk
#

this is far worse in performance

#

in comparsion to what they did

#

since in the server

#

u will have to basically reset the oreintation

#

every frame

#

so the more tanks u have the more worse the performance will get probably

#

it is far better to go with the previous option and do fastcast in the client

#

and instead of fastcast i would probably do hitscan as well

#

the reason for this is bc ur projectiles are very fast and dont really require physics simulation

timid breach
#

they go like 1.5k studs/s

#

or 1k

scenic musk
#

thats a lot of speed

timid breach
#

but they got bullet drop man

scenic musk
#

which basically means its just a straight line

#

u dont need bullet drop

#

they go too fast

#

they go beyond u can render at once anyway

scenic musk
timid breach
#

lkemdelkdeadmgjkernoginregmrwgoerwgre

scenic musk
#

stop using fastcast

#

and use hitcast

timid breach
#

where is security mtc has omg

scenic musk
#

i dont know man i dont know who that one is

#

but what i do know is fastcast is basically useless and worse in performace for ur needs

#

switch to just hitscan type detection

#

aka 1 straight line ray

timid breach
#

idk im not sure

#

the game needs bullet drop

timid breach
#

basically the only 2 solutions is client fastcast and this

scenic musk
#

if ur game does need bullet drop then

#

go for it

timid breach
#

what if i do 2 fastcast at same time???

#

one in the client and one in the server

scenic musk
#

thats what u are doing

#

something like that actually

#

since u need to validate the hit in the server somehow

#

well

#

in my opinion, for ur needs

#

hitscans better

#

tank bullets are very fast

#

but if u were to do this then do it on the server and the client each have their own pros and cons

timid breach
#

wait

#

is there a way to build a system to like

#

rewind physics

scenic musk
#

yeah

#

u can just

#

fastcast from endpoint bnack to origin

timid breach
#

to check if a hit should have really hit

scenic musk
#

thats not how u would do it i think

#

here read this super nerdy forum post i read

#
#

now

#

if u go to the very end the creator of fastcast goes on to tell u to not do it on the client

timid breach
#

yeah i saw it too

#

geromgwekll;p[l[pPOA,POAL,;AL;PFEWOPRE,OGER

scenic musk
#

i think ur best bet might just be wht i said

#

then again i dont know whats better

#

having multiple casts going on

#

or having to reset the orientation everyframe

timid breach
scenic musk
#

on the server for multiple tanks

#

yeah try that

#

regardless more tanks u have the worse it'll get

timid breach
#

wait

#

nvm i dont think this will work

scenic musk
#

the fix i said?

scenic musk
#

why not

timid breach
#

because server changes rotation almost same speed as client does

#

which is a problem i think

#

or im not sure

scenic musk
#

thats a good thing

#

u want the server and client to be in sync ideally

#

not sure what u mean

timid breach
#

visually its going to jitter a lot

#

for the gunner

#

or not?

scenic musk
#

ummm

#

not for the gunner

#

but for everyone else

#

well

timid breach
#

wait

scenic musk
#

yeah

timid breach
#

i think there is one way

#

ACTUALLY

#

u know

#

steel titans

#

right

#

or not

scenic musk
#

i know teen titans

#

not steel

timid breach
#

lol

#

well um

#

these guys

#

a

#

yes

#

these guys

#

on the server

#

a

#

wait

#

um

#

OK sorry im losing my iq

#

they changed the turret rotation at a much slower speed On the server than in the clients

scenic musk
#

its ok arent we all

#

thats what i said too

#

u use a click rotation system

#

that way it doesnt really matter

#

because u slowly rotate in the server

#

OH ALSO

#

because these tanks look rusty as hell

#

it might add to realism

#

hey

#

thats a bonus aint it

#

if its jittery good fo ru

timid breach
#

wait wdym rusty as hell

scenic musk
#

bro its a ww2 tank

#

no way it rotates perfectly

#

it has a little bit of stuck and rust

timid breach
#

i mean its gonna teleport around in a stable speed

#

on the server

#

i think

scenic musk
#

try it out and tell me what it ends up as

timid breach
#

yes not now tho im gonna take a break

scenic musk
#

ofc if it works i expect u to go around telling people ici helped u

timid breach
#

yes

#

of course

scenic musk
#

and when they ask u who is ici u tell them me

timid breach
#

u can get

#

credit

scenic musk
#

if it does not work

#

u stil tell them it was me

#

once it works

timid breach
#

if u want u can join my server and if game gets famous (totally realistic scenario) u can be in special thanks or idk what uwant

scenic musk
#

well

#

sure man why not

timid breach
tall dew
#

Hi, I would like to check out your tank game also. I will join

timid breach
#

@scenic musk hi you there?

timid breach
#

okkkkkk the bug has been fixed

#

i removed the hitbox it was worst idea ever

#

instead the server gets the turret orientation every 0.25 seconds now so the client is updating the rotation faster than the server does, so for the gunner's perspective it's gonna be as smooth as possible

#

and not every heartbeat otherwise the gunner controls will be way too sloppy