CineMachine: ------------------------------------------------------------------- public class pohyb : MonoBehaviour { [SerializeField] float rychlost = 500f; Rigidbody2D rb; // Start is called before the first frame update void Start() { rb = GetComponent(); } // Update is called once per frame void Update() { //print("Update"); if (Input.GetKeyDown(KeyCode.LeftArrow)) rb.AddForce(rychlost * Vector2.left); if (Input.GetKeyDown(KeyCode.RightArrow)) rb.AddForce(rychlost * Vector2.right); if (Input.GetKeyDown(KeyCode.Space)) rb.AddForce(rychlost * Vector2.up); } } ------------------------------------ public class PrepinaniKamer : MonoBehaviour { [SerializeField] Cinemachine.CinemachineVirtualCamera playerCamera; [SerializeField] Cinemachine.CinemachineVirtualCamera pokladCamera; [SerializeField] GameObject Player; [SerializeField] GameObject Poklad; [SerializeField] float JakBlizko = 5; // Update is called once per frame void Update() { if (Vector2.Distance(Player.transform.position, Poklad.transform.position) <= JakBlizko) pokladCamera.Priority = 100; else pokladCamera.Priority = 1; } } ------------------------------------ ################################################################################ InputSystem: ------------------------------------------------------------------- using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; public class Pohyb : MonoBehaviour { private @NewControls input = null; private Vector2 moveVector = Vector2.zero; private void Awake() { input = new @NewControls(); } private void OnEnable() { input.Enable(); input.Player.Movement.performed += onMovementPerformed; input.Player.Movement.canceled += onMovementCancelled; } private void OnDisable() { input.Disable(); input.Player.Movement.performed -= onMovementPerformed; input.Player.Movement.canceled -= onMovementCancelled; } private void onMovementPerformed(InputAction.CallbackContext value) { moveVector = value.ReadValue(); } private void onMovementCancelled(InputAction.CallbackContext value) { moveVector = Vector2.zero; } private void FixedUpdate() { Debug.Log(moveVector); } } ################################################################################ ################################################################################ ################################################################################ ################################################################################ ################################################################################ ################################################################################ ################################################################################ ------------------------------------ void Update() { if (Input.GetKey("left")) transform.Rotate(0, Time.deltaTime * -90, 0); if (Input.GetKey("right")) transform.Rotate(0, Time.deltaTime * 90, 0); if (Input.GetKey("up")) transform.Rotate(Time.deltaTime * 90, 0, 0); if (Input.GetKey("down")) transform.Rotate(Time.deltaTime * -90, 0, 0); } ------------------------------------ public GameObject PrefabKoule; ------------------------------------ float jakDlouhoNabijim = 0f; ------------------------------------ if (Input.GetKey(KeyCode.Space)) jakDlouhoNabijim += Time.deltaTime; else { if (jakDlouhoNabijim > 0f) // vystrelit: { float SILA = 1000f; Vector3 odkud = transform.position + Vector3.up; // aby nestrelil sam sebe GameObject koule = Instantiate(PrefabKoule, odkud, Quaternion.identity); Rigidbody krb = koule.GetComponent(); krb.AddForce(jakDlouhoNabijim * SILA * this.transform.forward); jakDlouhoNabijim = 0f; // abych nestrilel, dokud zase nenabiju } } ------------------------------------ public TMP_Text TextSilaVystrelu; ------------------------------------ TextSilaVystrelu.text = "Cas: "+123.45.ToString() + "s"; ------------------------------------ public AudioClip zvuk; ------------------------------------ AudioSource.PlayClipAtPoint(zvuk, transform.position); ------------------------------------