2 questions actually:
- When the mouse button is let go the “DestroyGrapple” is called from client and I want to destroy the earlier created GrapplingHookLinePrefab.
- “CreateHookLine” is run on client when button is pressed, I then want to create my prefab on server and keep updating the Origin with my position of my GunTransform. I don’t want to have to sync the positions for these since GunTransform is already a network identity that I sync.
private GameObject _line;
[Command]
void CreateHookLine(Vector3 position, Quaternion rotation, GameObject playerOwner)
{
_line = Instantiate(GrapplingHookLinePrefab, position, rotation);
var lineScript = _line.GetComponent<GrapplingHookLine>();
lineScript.PlayerOwner = playerOwner;
lineScript.Origin = GunTransform;
lineScript.Target = _grapplePoint;
NetworkServer.Spawn(_line, playerOwner);
}
[Command]
void DestroyGrapple()
{
NetworkServer.Destroy(_line);
}