informatica:realidad_virtual:unity:puzzle
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatica:realidad_virtual:unity:puzzle [2023/01/31 16:06] – jose | informatica:realidad_virtual:unity:puzzle [2023/01/31 17:21] (current) – jose | ||
---|---|---|---|
Line 7: | Line 7: | ||
{{: | {{: | ||
+ | |||
+ | Hay que jugar con la orientación. La flecha azul es la que manda. Cuando coges un objeto, lo coge por detrás, es decir, la flecha azul apunta hacía delante de ti y hay que girarlo añadiendo un " | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Y así lo metemos en " | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Ahora creamos los scripts. Creamos una carpeta en Assets que se llame scripts. Dentro de esa carpeta, botón derecho y " | ||
+ | |||
+ | El contenido del Script es el siguiente (tened en cuenta que el nombre del script es la clase principal) | ||
+ | |||
+ | < | ||
+ | using UnityEngine; | ||
+ | using UnityEngine.Events; | ||
+ | using UnityEngine.XR.Interaction.Toolkit; | ||
+ | |||
+ | |||
+ | public class EncajarFoto : MonoBehaviour | ||
+ | { | ||
+ | [SerializeField] private Transform CorrectPuzzlePiece; | ||
+ | private XRSocketInteractor socket; | ||
+ | |||
+ | [Header(" | ||
+ | public UnityEvent onPuzzleCompletion; | ||
+ | | ||
+ | private void Awake() => socket = GetComponent< | ||
+ | | ||
+ | private void OnEnable() | ||
+ | { | ||
+ | socket.selectEntered.AddListener(ObjectSnapped); | ||
+ | } | ||
+ | |||
+ | private void OnDisable() | ||
+ | { | ||
+ | socket.selectEntered.RemoveListener(ObjectSnapped); | ||
+ | } | ||
+ | |||
+ | private void ObjectSnapped(SelectEnterEventArgs arg0) | ||
+ | { | ||
+ | var snappedObjectName = arg0.interactableObject; | ||
+ | if(snappedObjectName.transform.name == CorrectPuzzlePiece.name) | ||
+ | { | ||
+ | onPuzzleCompletion.Invoke(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Arrastramos el script a " | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Aquí tenemos la variable " | ||
+ | |||
+ | Arrastramos nuestra foto a " | ||
+ | |||
+ | {{: | ||
+ | |||
informatica/realidad_virtual/unity/puzzle.1675181185.txt.gz · Last modified: by jose