#Question about GhostComponent, GhostField and IInputComponent

1 messages · Page 1 of 1 (latest)

fossil marlin
#

Hello, i'm trying to learn about unity netcode but Ghost prefab confused me.

[GhostComponent(PrefabType = GhostPrefabType.AllPredicted)]
public partial struct KeyboardInput : IInputComponentData
{
    public float2 MovementInput;
}

I'm using this component to sync my player's position, what i didn't understand is when i use this

[GhostComponent(PrefabType = GhostPrefabType.AllPredicted)]
public partial struct KeyboardInput : IComponentData
{
    [GhostField]
    public float2 MovementInput;
}

Server not sets the entity transform, why ?
The only way to set a entity's component data using IInputComponentData or ICommandData from client side ?

scarlet hill
#

ghost prefab must be predicted/owner predicter and have an owner set

fossil marlin
#

I already read that

#

So client only set IInputComponentData and ICommandData right ?

#

on an owned entity by the client

scarlet hill
#

it must be predicted as well

fossil marlin
#

okay cool

#

one more question

#

so player can change arbitrarily of these values

#

how can i prevent if a player sets movement to very big numbers to do a potential speed hack

scarlet hill
#

accept inputs that can't be hacked

fossil marlin
#

in the movement system right ?

scarlet hill
#

no

#

I mean

#

your IInputComponentData is only responsible for sending what keys of wasd are pressed

#

while server is responsible for speed

fossil marlin
#

yea

#

okay i guess i understood a bit better now