Skip to content

22 tore

Carlos Reiakvam requested to merge 22-tore into main

Created by: torebjerkan530599

Camera follows the individual network player

  • PlayerBehaviour.cs : movement vector is normalized
  • PlayerBehaviour.cs : get's a reference to the MainCamera when prefab is spawned on the network.
  • Camera starts to follow when edge of the square is reached by the avatar
  • Free movement within a small square in center of the screen
  • Temporary simple shapes in the hierarchy to have a reference for cameramovment (we can't tell if the camera is moving because there's no point of reference. The background is just a single color)

CleanUp/Refactor

  • PlayerBehaviour.cs : previous public fields are now private if it is not strictly neccessary that they are public.
  • SmallUnitHealth.cs : Same as above
  • If fields needs to be exposed to the Inspector, they have been marked with [SerializeField]

Issue

  • Jittery movment when the player is moving in -y direction/south. It is not a problem if camera is set to follow at all times.
  • Swapping the code in LateUpdate() in PlayerBehaviour.cs with
        if (IsLocalPlayer)
        {
            Vector3 pos = transform.position;
            pos.z = -10;
            mainCamera.transform.position = pos;
        }

fixes the problem, but now there is no square with freedom of movement. Camera will now follow all the time.

Merge request reports

Loading